addServe.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <view class="form-item">
  6. <text class="label">商品名称<text class="color-price">*</text></text>
  7. <input class="input-width" type="text" v-model="form.productName" placeholder="请输入商品名称"
  8. placeholder-class="form-input" />
  9. </view>
  10. <view class="form-item justify-between">
  11. <text class="label">购买数量<text class="color-price">*</text></text>
  12. <!-- <input class="input-width" type="number" v-model="" placeholder="请输入金额"
  13. placeholder-class="form-input" /> -->
  14. <view class="num-box"><u-number-box v-model="form.purchaseQuantity" integer></u-number-box></view>
  15. </view>
  16. <view class="form-item">
  17. <text class="label">金额<text class="color-price">*</text></text>
  18. <input class="input-width" type="digit" v-model="form.amount" placeholder="请输入金额"
  19. placeholder-class="form-input" />
  20. </view>
  21. <view class="form-item">
  22. <text class="label">预计用完时间<text class="color-price">*</text></text>
  23. <picker class="birth-picker" mode="date" :start="startDate" @change="bindDateChange">
  24. <view class="right-box">
  25. <view class="input-box">
  26. <input type="text" :value="form.plannedCompletionDate" placeholder="请选择时间" placeholder-class="form-input" disabled="disabled" />
  27. </view>
  28. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  29. </view>
  30. </picker>
  31. </view>
  32. <view class="form-item">
  33. <text class="label">购买次数<text class="color-price">*</text></text>
  34. <input class="input-width" type="number" v-model="form.purchaseTimes" placeholder="请输入购买次数"
  35. placeholder-class="form-input" />
  36. </view>
  37. <view class="form-item">
  38. <text class="label">剩余次数<text class="color-price">*</text></text>
  39. <input class="input-width" type="number" v-model="form.surplusTimes" placeholder="请输入剩余次数"
  40. placeholder-class="form-input" />
  41. </view>
  42. <view class="form-item">
  43. <text class="label">会员情况<text class="color-price">*</text></text>
  44. <input class="input-width" type="text" v-model="form.memberStatus" placeholder="请输入会员情况"
  45. placeholder-class="form-input" />
  46. </view>
  47. </view>
  48. </view>
  49. <view class="btn-box">
  50. <view class="sub-btn" @click="submit()">
  51. <image src="/static/images/health/nav_add_icon24.png" class="w48 h48"></image>
  52. <text>新增商品信息</text>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. getServiceById,updateService,saveService
  60. } from '@/api/companyUser.js'
  61. export default {
  62. data() {
  63. return {
  64. startDate:this.utils.timeFormat(new Date()),
  65. type: null,
  66. patientId: null,
  67. famaleurl:"/static/images/health/female_profile.png",
  68. maleurl:"/static/images/health/my_heads.png",
  69. checked:1,
  70. array:['是','否'],
  71. tags: [{
  72. name: '心脏病',
  73. checked:true,
  74. id: 1
  75. },
  76. {
  77. name: '脑梗死',
  78. checked:false,
  79. id: 2
  80. },{
  81. name: '肾病',
  82. checked:false,
  83. id: 3
  84. },{
  85. name: '脂肪肝',
  86. checked:false,
  87. id: 4
  88. }],
  89. form: {
  90. "amount": null,
  91. "memberStatus": null,
  92. "plannedCompletionDate": null,
  93. "productName":null,
  94. "purchaseQuantity":1,
  95. "purchaseTimes":null,
  96. "remark": null,
  97. "surplusTimes":null,
  98. },
  99. id:null
  100. };
  101. },
  102. onLoad(options) {
  103. this.type = options.type;
  104. this.form.userId=options.userId
  105. this.form.companyUserId=options.companyUserId;
  106. console.log(this.type)
  107. if (this.type == 'edit') {
  108. this.id=options.id;
  109. this.getServiceInfo();
  110. }
  111. },
  112. methods: {
  113. sexChange(type) {
  114. this.form.sex = type
  115. },
  116. radioClick(item) {
  117. this.checked=item.id
  118. },
  119. getServiceInfo() {
  120. var data = {
  121. id: this.id
  122. };
  123. getServiceById(data).then(
  124. res => {
  125. if (res.code == 200) {
  126. this.form = res.data;
  127. this.form.plannedCompletionDate=this.utils.timeFormat(res.data.plannedCompletionDate,'yyyy-mm-dd')
  128. this.startDate=this.form.plannedCompletionDate
  129. } else {
  130. uni.showToast({
  131. title: res.msg,
  132. });
  133. }
  134. },
  135. rej => {}
  136. );
  137. },
  138. submit() {
  139. if (this.form.productName == null) {
  140. uni.showToast({
  141. icon: 'none',
  142. title: "名称不能为空",
  143. });
  144. return;
  145. }
  146. if (this.form.purchaseQuantity == null) {
  147. uni.showToast({
  148. icon: 'none',
  149. title: "数量不能为空",
  150. });
  151. return;
  152. }
  153. if (this.form.amount == null) {
  154. uni.showToast({
  155. icon: 'none',
  156. title: "金额不能为空",
  157. });
  158. return;
  159. }
  160. if (this.form.plannedCompletionDate == null) {
  161. uni.showToast({
  162. icon: 'none',
  163. title: "时间不能为空",
  164. });
  165. return;
  166. }
  167. if (this.form.purchaseTimes == null) {
  168. uni.showToast({
  169. icon: 'none',
  170. title: "购买次数不能为空",
  171. });
  172. return;
  173. }
  174. if (this.form.surplusTimes == null) {
  175. uni.showToast({
  176. icon: 'none',
  177. title: "剩余次数不能为空",
  178. });
  179. return;
  180. }
  181. if (this.form.memberStatus == null) {
  182. uni.showToast({
  183. icon: 'none',
  184. title: "会员情况不能为空",
  185. });
  186. return;
  187. }
  188. if (this.type == "add") {
  189. this.saveService()
  190. } else if (this.type == "edit") {
  191. this.updateService()
  192. }
  193. },
  194. updateService() {
  195. updateService(this.form).then(
  196. res => {
  197. if (res.code == 200) {
  198. uni.showToast({
  199. icon: 'success',
  200. title: "操作成功",
  201. });
  202. setTimeout(function() {
  203. uni.$emit('refreshBuyOrder');
  204. uni.navigateBack({
  205. delta: 1
  206. })
  207. }, 500);
  208. } else {
  209. uni.showToast({
  210. icon: 'none',
  211. title: res.msg,
  212. });
  213. }
  214. },
  215. rej => {}
  216. );
  217. },
  218. saveService() {
  219. saveService(this.form).then(
  220. res => {
  221. if (res.code == 200) {
  222. uni.showToast({
  223. icon: 'success',
  224. title: "操作成功",
  225. });
  226. setTimeout(function() {
  227. uni.$emit('refreshBuyOrder');
  228. uni.navigateBack({
  229. delta: 1
  230. })
  231. }, 500);
  232. } else {
  233. uni.showToast({
  234. icon: 'none',
  235. title: res.msg,
  236. });
  237. }
  238. },
  239. rej => {}
  240. );
  241. },
  242. // 出生日期选择
  243. bindDateChange: function(e) {
  244. this.form.plannedCompletionDate = e.target.value
  245. },
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. page {
  251. height: 100%;
  252. }
  253. .content {
  254. height: 100%;
  255. display: flex;
  256. flex-direction: column;
  257. justify-content: space-between;
  258. .inner {
  259. // height: calc(100% - 120upx);
  260. padding: 20upx;
  261. .form-box {
  262. padding: 0 30upx;
  263. background: #FFFFFF;
  264. border-radius: 16upx;
  265. margin-bottom: 20upx;
  266. .form-title {
  267. font-family: PingFang SC;
  268. font-weight: 600;
  269. font-size: 40rpx;
  270. color: #222426;
  271. text-align: left;
  272. padding: 30rpx 0;
  273. display: block;
  274. }
  275. .form-item {
  276. padding: 30upx 0;
  277. display: flex;
  278. align-items: flex-start;
  279. border-bottom: 1px solid #F1F1F1;
  280. &:last-child {
  281. border-bottom: none;
  282. }
  283. .label {
  284. width: 300upx;
  285. text-align: left;
  286. font-size: 32upx;
  287. line-height: 44upx;
  288. font-family: PingFang SC;
  289. font-weight: 500;
  290. color: #222222;
  291. flex-shrink: 0;
  292. }
  293. input {
  294. text-align: right;
  295. }
  296. .num-box{
  297. input{
  298. text-align: center !important;
  299. }
  300. }
  301. .form-input {
  302. font-size: 30upx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #999999;
  306. text-align: right;
  307. }
  308. .form-item-tag{
  309. margin-right: 16rpx;
  310. .tag{
  311. border-radius: 8rpx 8rpx 8rpx 8rpx;
  312. border: 2rpx solid #ECECEC;
  313. display: flex;
  314. align-items: center;
  315. padding: 24rpx;
  316. font-family: PingFang SC;
  317. font-weight: 400;
  318. font-size: 24rpx;
  319. &.active{
  320. background: #F0FAFF;
  321. border: 2rpx solid #008FD3;
  322. color: #008FD3;
  323. }
  324. }
  325. }
  326. .right{
  327. display: flex;
  328. align-items: center;
  329. }
  330. .sex-box{
  331. flex:1;
  332. display: flex;
  333. align-items: center;
  334. justify-content: flex-end;
  335. .sex-item{
  336. width: 146rpx;
  337. height: 64rpx;
  338. display: flex;
  339. align-items: center;
  340. justify-content: center;
  341. background: #F5F7FA;
  342. border-radius: 32rpx 32rpx 32rpx 32rpx;
  343. margin-left: 16rpx;
  344. .u-icon__icon{
  345. margin: 0;
  346. }
  347. text{
  348. // font-family: PingFang SC, PingFang SC;
  349. font-weight: 400;
  350. font-size: 28rpx;
  351. color: #898E91;
  352. margin-left: 12rpx;
  353. }
  354. &.active{
  355. background: #FCF0E7;
  356. text{
  357. color:#FF5030
  358. }
  359. }
  360. }
  361. }
  362. .form-textarea{
  363. font-size: 30upx;
  364. color: #999999;
  365. height: 100upx;
  366. padding: 4upx 0;
  367. }
  368. .birth-picker {
  369. flex: 1;
  370. display: flex;
  371. align-items: center;
  372. .right-box{
  373. width: 100%;
  374. display: flex;
  375. align-items: center;
  376. .input-box{
  377. // width: 470upx;
  378. }
  379. .arrow{
  380. width: 13upx;
  381. height: 23upx;
  382. margin-left: 20upx;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. .btn-box {
  390. height: 120upx;
  391. padding: 0 30upx;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. // position: fixed;
  396. // width: 90%;
  397. // bottom: 0;
  398. // left: 50%;
  399. // transform: translate(-50%,-50%);
  400. // background: #FFFFFF;
  401. .sub-btn {
  402. width: 100%;
  403. height: 88upx;
  404. line-height: 88upx;
  405. text-align: center;
  406. font-size: 32upx;
  407. font-family: PingFang SC;
  408. font-weight: bold;
  409. color: #FFFFFF;
  410. background: #008FD3 ;
  411. border-radius: 44upx;
  412. margin-bottom: 40upx;
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. image{
  417. margin-right: 16rpx;
  418. }
  419. }
  420. }
  421. }
  422. </style>