addIndicator.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <template>
  2. <view class="content">
  3. <view class="form-box">
  4. <!-- 设为默认地址 -->
  5. <view class="form-item">
  6. <text class="label">指标类型</text>
  7. <view class="switch align-center justify-center">
  8. <view v-for="(item,index) in tags" :key="index" :class="aIndex==index?'item active':'item'" @click="changeTag(item,index)">
  9. {{item.name}}
  10. </view>
  11. </view>
  12. </view>
  13. <view class="form-item">
  14. <text class="label">指标名称</text>
  15. <input type="text" v-model="form.indicatorName" placeholder="请输入名称" placeholder-class="form-input"/>
  16. </view>
  17. <view class="form-item">
  18. <text class="label">指标分类</text>
  19. <picker class="birth-picker" mode="selector" :range="list" range-key="dictLabel" @change="bindTagsChange($event,list)">
  20. <view class="right-box">
  21. <view class="input-box">
  22. <input type="text" :value="indicatorCategory" placeholder="请选择指标分类" placeholder-class="form-input" disabled="disabled" />
  23. </view>
  24. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png" mode=""></image>
  25. </view>
  26. </picker>
  27. </view>
  28. <view class="form-item">
  29. <text class="label">指标单位</text>
  30. <picker class="birth-picker" mode="selector" :range="cates" range-key="unitSymbol" @change="bindUnitChange($event,cates)">
  31. <view class="right-box">
  32. <view class="input-box">
  33. <input type="text" :value="unitName" placeholder="请选择指标单位" placeholder-class="form-input" disabled="disabled" />
  34. </view>
  35. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png" mode=""></image>
  36. </view>
  37. </picker>
  38. </view>
  39. <view class="form-item">
  40. <text class="label">参考值范围</text>
  41. <view class="align-center">
  42. <input type="digit" v-model="form.referenceMin" placeholder="数值下限" placeholder-class="form-input" class="input-width"/>
  43. <view class="to">-</view>
  44. <input type="digit" v-model="form.referenceMax" placeholder="数值上限" placeholder-class="form-input" class="input-width"/>
  45. </view>
  46. </view>
  47. <view class="note">
  48. 备注:若无参考值可不埌写,若该指标无上(下)限时可只填写其中一项
  49. </view>
  50. </view>
  51. <view class="btn-box2">
  52. <view class="sub-btn" @click="submit()">
  53. 确认
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {getDictByKey} from '@/api/common.js'
  60. import {addIndicator,updateIndicator,getListAll,getIndicatorById} from '@/api/companyUser.js'
  61. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  62. export default {
  63. mixins: [MescrollMixin],
  64. data() {
  65. return {
  66. orderStatus:[
  67. {name:"电话记录",val:1},
  68. {name:"短信记录",val:2},
  69. ],
  70. unitName:null,
  71. indicatorCategory:null,
  72. aIndex:0,
  73. cates:[],
  74. tags:[{
  75. name:'数值',
  76. value:0
  77. },{
  78. name:'二元',
  79. value:1
  80. }],
  81. list:[],
  82. showType:1,
  83. mescroll:null,
  84. // 上拉加载的配置
  85. upOption: {
  86. onScroll:true,
  87. use: true, // 是否启用上拉加载; 默认true
  88. page: {
  89. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  90. size: 10 // 每页数据的数量,默认10
  91. },
  92. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  93. empty: {
  94. icon:'/static/images/no_data.png',
  95. tip: '暂无数据'
  96. }
  97. },
  98. // 列表数据
  99. dataList: [
  100. {orderId:1, name:'今日 11:22',time:'4分16秒'},
  101. {orderId:2, name:'昨天 09:16',time:'4分16秒'},
  102. {orderId:3, name:'1月12 13:06',time:'4分16秒'}
  103. ],
  104. dataList2: [
  105. {orderId:1,content:'服用胰岛素口服液 规格20mg*20 每次1片1日一次 用法口服',state:'已送达',time:'2025-2-20 10:29',},
  106. {orderId:2,content:'服用胰岛素口服液 规格20mg*20 每次1片1日一次 用法口服',state:'已送达',time:'2025-2-20 10:29',},
  107. {orderId:3,content:'服用胰岛素口服液 规格20mg*20 每次1片1日一次 用法口服',state:'已送达',time:'2025-2-20 10:29',}
  108. ],
  109. form:{
  110. status:1,
  111. // "indicatorCategory": "0",
  112. type:0
  113. }
  114. }
  115. },
  116. onLoad(options) {
  117. this.type=options.type
  118. this.getDictByKey('user_custom_type')
  119. this.getListAll()
  120. if(this.type=='edit'){
  121. this.indicatorId=options.id;
  122. this.getIndicatorById();
  123. uni.setNavigationBarTitle({
  124. title:'编辑指标'
  125. })
  126. }
  127. // uni.$on('refreshDoctorOrder', () => {
  128. // this.mescroll.resetUpScroll()
  129. // })
  130. },
  131. methods: {
  132. changeTag(item,index){
  133. this.aIndex=index
  134. this.form.type=item.value
  135. },
  136. bindTagsChange:function(e,list) {
  137. this.indicatorCategory=list[e.target.value].dictLabel
  138. this.form.indicatorCategory = list[e.target.value].dictValue
  139. },
  140. bindUnitChange:function(e,list) {
  141. this.unitName=list[e.target.value].unitSymbol
  142. this.form.unitId = list[e.target.value].unitId
  143. },
  144. getListAll(){
  145. getListAll().then(
  146. res => {
  147. if(res.code==200){
  148. this.cates=res.data;
  149. }else{
  150. uni.showToast({
  151. title: res.msg,
  152. });
  153. }
  154. },
  155. rej => {}
  156. );
  157. },
  158. getDictByKey(key) {
  159. var data = {
  160. key: key
  161. }
  162. getDictByKey(data).then(
  163. res => {
  164. if (res.code == 200) {
  165. this.list = res.data;
  166. }
  167. },
  168. err => {}
  169. );
  170. },
  171. getIndicatorById(){
  172. getIndicatorById(this.indicatorId).then(
  173. res => {
  174. if(res.code==200){
  175. this.form=res.data;
  176. const unit = this.cates.find(item => item.unitId ==this.form.unitId);
  177. // 安全地获取单位名称,避免空数组错误
  178. this.unitName = unit ? unit.unitSymbol : '';
  179. const indicatorCategory = this.list.find(item => item.dictValue ==this.form.indicatorCategory);
  180. this.indicatorCategory= indicatorCategory ? indicatorCategory.dictLabel : '';
  181. }else{
  182. uni.showToast({
  183. title: res.msg,
  184. });
  185. }
  186. },
  187. rej => {}
  188. );
  189. },
  190. submit(){
  191. if(this.form.indicatorName==null){
  192. uni.showToast({
  193. icon:'none',
  194. title: "指标名称不能为空",
  195. });
  196. return;
  197. }
  198. if(this.form.unitId==null){
  199. uni.showToast({
  200. icon:'none',
  201. title: "单位不能为空",
  202. });
  203. return;
  204. }
  205. if(this.form.indicatorCategory==null){
  206. uni.showToast({
  207. icon:'none',
  208. title: "指标分类不能为空",
  209. });
  210. return;
  211. }
  212. // if(this.form.referenceMax==null){
  213. // uni.showToast({
  214. // icon:'none',
  215. // title: "参考值最大值不能为空",
  216. // });
  217. // return;
  218. // }
  219. if(this.type=="add"){
  220. this.addIndicator()
  221. }
  222. else if(this.type=="edit"){
  223. this.updateIndicator()
  224. }
  225. },
  226. updateIndicator(){
  227. updateIndicator(this.form).then(
  228. res => {
  229. if(res.code==200){
  230. uni.showToast({
  231. icon:'success',
  232. title: "更新成功",
  233. });
  234. setTimeout(function() {
  235. uni.$emit('refreshEditIndicator');
  236. uni.navigateBack({
  237. delta: 1
  238. })
  239. }, 500);
  240. }else{
  241. uni.showToast({
  242. icon:'none',
  243. title: res.msg,
  244. });
  245. }
  246. },
  247. rej => {}
  248. );
  249. },
  250. addIndicator(){
  251. addIndicator(this.form).then(
  252. res => {
  253. if(res.code==200){
  254. uni.showToast({
  255. icon:'success',
  256. title: "操作成功",
  257. });
  258. setTimeout(function() {
  259. uni.$emit('refreshEditIndicator');
  260. uni.navigateBack({
  261. delta: 1
  262. })
  263. }, 500);
  264. }else{
  265. uni.showToast({
  266. icon:'none',
  267. title: res.msg,
  268. });
  269. }
  270. },
  271. rej => {}
  272. );
  273. },
  274. cancel(item){
  275. var that=this;
  276. uni.showModal({
  277. title: '提示',
  278. content: '确定取消订单吗',
  279. success: function (res) {
  280. if (res.confirm) {
  281. var data = {
  282. orderId:item.orderId
  283. };
  284. cancelOrder(data).then(res => {
  285. if(res.code==200){
  286. uni.showToast({
  287. icon:'success',
  288. title: '订单已取消',
  289. });
  290. that.mescroll.resetUpScroll()
  291. }else{
  292. uni.showToast({
  293. icon:'none',
  294. title: res.msg,
  295. });
  296. }
  297. });
  298. }
  299. else if (res.cancel) {
  300. }
  301. }
  302. });
  303. },
  304. // tab切换
  305. orderStatusChange(item) {
  306. this.showType = item.val
  307. this.mescroll.resetUpScroll()
  308. },
  309. mescrollInit(mescroll) {
  310. this.mescroll = mescroll;
  311. },
  312. /*下拉刷新的回调 */
  313. downCallback(mescroll) {
  314. mescroll.resetUpScroll()
  315. },
  316. showDetail(item) {
  317. if(item.orderType==1){
  318. uni.navigateTo({
  319. url: '/pages_doctor/doctorOrderIM?orderId='+item.orderId
  320. })
  321. }
  322. }
  323. }
  324. }
  325. </script>
  326. <style lang="scss">
  327. .content{
  328. padding: 20upx;
  329. .form-box{
  330. // padding: 0 30upx;
  331. // background: #FFFFFF;
  332. // border-radius: 16upx;
  333. .form-item{
  334. padding: 30upx;
  335. display: flex;
  336. align-items: center;
  337. justify-content: space-between;
  338. background: #FFFFFF;
  339. border-radius: 16rpx 16rpx 16rpx 16rpx;
  340. margin-bottom: 20rpx;
  341. // border-bottom: 1px solid #F1F1F1;
  342. &:last-child{
  343. margin-bottom:0;
  344. }
  345. .label{
  346. font-family: PingFang SC, PingFang SC;
  347. font-weight: 500;
  348. font-size: 32rpx;
  349. color: #222426;
  350. line-height: 34rpx;
  351. text-align: left;
  352. }
  353. input{
  354. text-align: right;
  355. }
  356. .to{
  357. color: #626468;
  358. margin: 0 20rpx;
  359. }
  360. .switch{
  361. width: 232rpx;
  362. height: 72rpx;
  363. background: #FFFFFF;
  364. border-radius: 36rpx 36rpx 36rpx 36rpx;
  365. border: 2rpx solid #008FD3;
  366. .item{
  367. width: 112rpx;
  368. height: 64rpx;
  369. line-height: 63rpx;
  370. font-weight: 400;
  371. font-size: 24rpx;
  372. color: #008FD3;
  373. text-align: center;
  374. &.active{
  375. color: #FFFFFF;
  376. background: #008FD3;
  377. border-radius: 32rpx 32rpx 32rpx 32rpx;
  378. }
  379. }
  380. }
  381. .form-input{
  382. font-size: 32upx;
  383. font-family: PingFang SC;
  384. font-weight: 400;
  385. color: #999999;
  386. text-align: right;
  387. }
  388. // .form-input2{
  389. // font-size: 32upx;
  390. // font-family: PingFang SC;
  391. // font-weight: 400;
  392. // color: #999999;
  393. // text-align: right;
  394. // }
  395. .input-width{
  396. width: 150rpx;
  397. // font-size: 32upx;
  398. // font-family: PingFang SC;
  399. // font-weight: 400;
  400. // color: #999999;
  401. text-align:center;
  402. }
  403. .birth-picker {
  404. flex: 1;
  405. display: flex;
  406. align-items: center;
  407. .right-box{
  408. width: 100%;
  409. display: flex;
  410. align-items: center;
  411. .input-box{
  412. width: 470upx;
  413. }
  414. .arrow{
  415. width: 13upx;
  416. height: 23upx;
  417. margin-left: 20upx;
  418. }
  419. }
  420. }
  421. }
  422. .note{
  423. font-family: PingFang SC, PingFang SC;
  424. font-weight: 400;
  425. font-size: 24rpx;
  426. color: #898E91;
  427. text-align: left;
  428. }
  429. }
  430. .btn-box2{
  431. z-index: 9999;
  432. width: 100%;
  433. padding: 30upx;
  434. // position: fixed;
  435. bottom: 0;
  436. left: 0;
  437. box-sizing: border-box;
  438. // background: #FFFFFF;
  439. display: flex;
  440. align-items: center;
  441. justify-content: space-between;
  442. padding-bottom: 40rpx;
  443. .sub-btn{
  444. flex:1;
  445. // width: 100%;
  446. height: 88upx;
  447. line-height: 88upx;
  448. text-align: center;
  449. font-size: 32upx;
  450. font-family: PingFang SC;
  451. font-weight: bold;
  452. color: #FFFFFF;
  453. background: #008FD3;
  454. border-radius: 44upx;
  455. display: flex;
  456. align-items: center;
  457. border: 2rpx solid #008FD3;
  458. justify-content: center;
  459. image{
  460. margin-right: 16rpx;
  461. }
  462. }
  463. .sub-btn2{
  464. flex:1;
  465. height: 88upx;
  466. line-height: 88upx;
  467. text-align: center;
  468. font-size: 32rpx;
  469. color: #008FD3;
  470. font-family: PingFang SC;
  471. font-weight: bold;
  472. background: #FFFFFF;
  473. border-radius: 44rpx 44rpx 44rpx 44rpx;
  474. border: 2rpx solid #008FD3;
  475. margin-right: 20rpx;
  476. }
  477. }
  478. .phone-list{
  479. // padding: 30rpx;
  480. .item{
  481. display: flex;
  482. align-items: center;
  483. justify-content: space-between;
  484. background: #FFFFFF;
  485. border-radius: 16rpx 16rpx 16rpx 16rpx;
  486. // border-bottom: 1rpx solid #ECECEC;
  487. padding: 20rpx;
  488. margin-bottom: 20rpx;
  489. &:last-child{
  490. margin-bottom: 0;
  491. }
  492. .phone-name{
  493. display: flex;
  494. flex-direction: column;
  495. align-items: flex-start;
  496. // justify-content: flex-start;
  497. // padding-left: 24rpx;
  498. flex: 1;
  499. .name{
  500. font-family: PingFang SC, PingFang SC;
  501. font-weight: 500;
  502. font-size: 32rpx;
  503. color: #222426;
  504. text-align: left;
  505. }
  506. .type{
  507. font-family: PingFang SC;
  508. font-weight: 400;
  509. font-size: 28rpx;
  510. color: #626468;
  511. text-align: right;
  512. }
  513. .time{
  514. font-family: PingFang SC;
  515. font-weight: 400;
  516. font-size: 24rpx;
  517. color: #898E91;
  518. text-align: left;
  519. margin-top: 14rpx;
  520. }
  521. }
  522. }
  523. }
  524. .sms-list{
  525. .item{
  526. padding: 30rpx;
  527. background: #FFFFFF;
  528. border-radius: 16rpx 16rpx 16rpx 16rpx;
  529. margin-bottom: 20rpx;
  530. .title{
  531. font-family: PingFang SC;
  532. font-weight: 500;
  533. font-size: 32rpx;
  534. color: #222426;
  535. text-align: left;
  536. }
  537. .box{
  538. display: flex;
  539. align-items: center;
  540. justify-content: space-between;
  541. padding-top: 22rpx;
  542. .time{
  543. font-family: PingFang SC;
  544. font-weight: 400;
  545. font-size: 24rpx;
  546. color: #898E91;
  547. text-align: left;
  548. }
  549. .state{
  550. font-family: PingFang SC;
  551. font-weight: 400;
  552. font-size: 24rpx;
  553. color: #2CAE5C;
  554. text-align: right;
  555. }
  556. }
  557. }
  558. }
  559. }
  560. </style>