addServe.vue 9.4 KB

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