123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- <template>
- <view class="content">
- <view class="inner">
- <view class="form-box">
- <view class="form-item">
- <text class="label">商品名称<text class="color-price">*</text></text>
- <input class="input-width" type="text" v-model="form.productName" placeholder="请输入商品名称"
- placeholder-class="form-input" />
- </view>
- <view class="form-item justify-between">
- <text class="label">购买数量<text class="color-price">*</text></text>
- <!-- <input class="input-width" type="number" v-model="" placeholder="请输入金额"
- placeholder-class="form-input" /> -->
- <view class="num-box"><u-number-box v-model="form.purchaseQuantity" integer></u-number-box></view>
- </view>
- <view class="form-item">
- <text class="label">金额<text class="color-price">*</text></text>
- <input class="input-width" type="digit" v-model="form.amount" placeholder="请输入金额"
- placeholder-class="form-input" />
- </view>
- <view class="form-item">
- <text class="label">预计用完时间<text class="color-price">*</text></text>
- <picker class="birth-picker" mode="date" :start="startDate" @change="bindDateChange">
- <view class="right-box">
- <view class="input-box">
- <input type="text" :value="form.plannedCompletionDate" placeholder="请选择时间" placeholder-class="form-input" disabled="disabled" />
- </view>
- <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
- </view>
- </picker>
- </view>
- <view class="form-item">
- <text class="label">购买次数<text class="color-price">*</text></text>
- <input class="input-width" type="number" v-model="form.purchaseTimes" placeholder="请输入购买次数"
- placeholder-class="form-input" />
- </view>
- <view class="form-item">
- <text class="label">剩余次数<text class="color-price">*</text></text>
- <input class="input-width" type="number" v-model="form.surplusTimes" placeholder="请输入剩余次数"
- placeholder-class="form-input" />
- </view>
- <view class="form-item">
- <text class="label">会员情况<text class="color-price">*</text></text>
- <input class="input-width" type="text" v-model="form.memberStatus" placeholder="请输入会员情况"
- placeholder-class="form-input" />
- </view>
- </view>
- </view>
- <view class="btn-box">
- <view class="sub-btn" @click="submit()">
- <image src="/static/images/health/nav_add_icon24.png" class="w48 h48"></image>
- <text>新增商品信息</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getServiceById,updateService,saveService
- } from '@/api/companyUser.js'
- export default {
- data() {
- return {
- startDate:this.utils.timeFormat(new Date()),
- type: null,
- patientId: null,
- famaleurl:"/static/images/health/female_profile.png",
- maleurl:"/static/images/health/my_heads.png",
- checked:1,
- array:['是','否'],
- tags: [{
- name: '心脏病',
- checked:true,
- id: 1
- },
- {
- name: '脑梗死',
- checked:false,
- id: 2
- },{
- name: '肾病',
- checked:false,
- id: 3
- },{
- name: '脂肪肝',
- checked:false,
- id: 4
- }],
- form: {
- "amount": null,
- "memberStatus": null,
- "plannedCompletionDate": null,
- "productName":null,
- "purchaseQuantity":1,
- "purchaseTimes":null,
- "remark": null,
- "surplusTimes":null,
- },
- id:null
- };
- },
- onLoad(options) {
- this.type = options.type;
- this.form.userId=options.userId
- this.form.companyUserId=options.companyUserId;
- console.log(this.type)
- if (this.type == 'edit') {
- this.id=options.id;
- this.getServiceInfo();
- }
- },
- methods: {
- sexChange(type) {
- this.form.sex = type
- },
- radioClick(item) {
- this.checked=item.id
- },
- getServiceInfo() {
- var data = {
- id: this.id
- };
- getServiceById(data).then(
- res => {
- if (res.code == 200) {
- this.form = res.data;
- this.form.plannedCompletionDate=this.utils.timeFormat(res.data.plannedCompletionDate,'yyyy-mm-dd')
- this.startDate=this.form.plannedCompletionDate
- } else {
- uni.showToast({
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- submit() {
- if (this.form.productName == null) {
- uni.showToast({
- icon: 'none',
- title: "名称不能为空",
- });
- return;
- }
- if (this.form.purchaseQuantity == null) {
- uni.showToast({
- icon: 'none',
- title: "数量不能为空",
- });
- return;
- }
- if (this.form.amount == null) {
- uni.showToast({
- icon: 'none',
- title: "金额不能为空",
- });
- return;
- }
- if (this.form.plannedCompletionDate == null) {
- uni.showToast({
- icon: 'none',
- title: "时间不能为空",
- });
- return;
- }
- if (this.form.purchaseTimes == null) {
- uni.showToast({
- icon: 'none',
- title: "购买次数不能为空",
- });
- return;
- }
- if (this.form.surplusTimes == null) {
- uni.showToast({
- icon: 'none',
- title: "剩余次数不能为空",
- });
- return;
- }
- if (this.form.memberStatus == null) {
- uni.showToast({
- icon: 'none',
- title: "会员情况不能为空",
- });
- return;
- }
- if (this.type == "add") {
- this.saveService()
- } else if (this.type == "edit") {
- this.updateService()
- }
-
- },
- updateService() {
- updateService(this.form).then(
- res => {
- if (res.code == 200) {
- uni.showToast({
- icon: 'success',
- title: "操作成功",
- });
- setTimeout(function() {
- uni.$emit('refreshBuyOrder');
- uni.navigateBack({
- delta: 1
- })
- }, 500);
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- saveService() {
- saveService(this.form).then(
- res => {
- if (res.code == 200) {
- uni.showToast({
- icon: 'success',
- title: "操作成功",
- });
- setTimeout(function() {
- uni.$emit('refreshBuyOrder');
- uni.navigateBack({
- delta: 1
- })
- }, 500);
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- // 出生日期选择
- bindDateChange: function(e) {
- this.form.plannedCompletionDate = e.target.value
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- height: 100%;
- }
- .content {
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .inner {
- // height: calc(100% - 120upx);
- padding: 20upx;
- .form-box {
- padding: 0 30upx;
- background: #FFFFFF;
- border-radius: 16upx;
- margin-bottom: 20upx;
- .form-title {
- font-family: PingFang SC;
- font-weight: 600;
- font-size: 40rpx;
- color: #222426;
- text-align: left;
- padding: 30rpx 0;
- display: block;
- }
- .form-item {
- padding: 30upx 0;
- display: flex;
- align-items: flex-start;
- border-bottom: 1px solid #F1F1F1;
- &:last-child {
- border-bottom: none;
- }
-
- .label {
- width: 300upx;
- text-align: left;
- font-size: 32upx;
- line-height: 44upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #222222;
- flex-shrink: 0;
- }
-
- input {
- text-align: right;
- }
- .num-box{
- input{
- text-align: center !important;
- }
- }
- .form-input {
- font-size: 30upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- text-align: right;
- }
- .form-item-tag{
- margin-right: 16rpx;
- .tag{
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- border: 2rpx solid #ECECEC;
- display: flex;
- align-items: center;
- padding: 24rpx;
- font-family: PingFang SC;
- font-weight: 400;
- font-size: 24rpx;
- &.active{
- background: #F0FAFF;
- border: 2rpx solid #008FD3;
- color: #008FD3;
- }
- }
-
-
-
- }
- .right{
- display: flex;
- align-items: center;
- }
- .sex-box{
- flex:1;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .sex-item{
- width: 146rpx;
- height: 64rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background: #F5F7FA;
- border-radius: 32rpx 32rpx 32rpx 32rpx;
- margin-left: 16rpx;
- .u-icon__icon{
- margin: 0;
- }
- text{
- // font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #898E91;
- margin-left: 12rpx;
- }
- &.active{
- background: #FCF0E7;
- text{
- color:#FF5030
- }
- }
- }
- }
- .form-textarea{
- font-size: 30upx;
- color: #999999;
- height: 100upx;
- padding: 4upx 0;
- }
-
- .birth-picker {
- flex: 1;
- display: flex;
- align-items: center;
-
- .right-box{
- width: 100%;
- display: flex;
- align-items: center;
- .input-box{
- // width: 470upx;
- }
- .arrow{
- width: 13upx;
- height: 23upx;
- margin-left: 20upx;
- }
- }
- }
- }
- }
- }
- .btn-box {
- height: 120upx;
- padding: 0 30upx;
- display: flex;
- align-items: center;
- justify-content: center;
- // position: fixed;
- // width: 90%;
- // bottom: 0;
- // left: 50%;
- // transform: translate(-50%,-50%);
- // background: #FFFFFF;
- .sub-btn {
- width: 100%;
- height: 88upx;
- line-height: 88upx;
- text-align: center;
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- background: #008FD3 ;
- border-radius: 44upx;
- margin-bottom: 40upx;
- display: flex;
- align-items: center;
- justify-content: center;
- image{
- margin-right: 16rpx;
- }
- }
- }
- }
- </style>
|