editIndicator.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <view class="search-cont">
  5. <view class="inner2">
  6. <image class="icon-search" src="/static/images/search.png" mode=""></image>
  7. <input type="text" v-model="keyword" placeholder="请输入想要搜索的指标" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  8. </view>
  9. </view>
  10. <!-- <u-search bgColor="#F5F7FA" placeholder="请输入想要搜索的指标" v-model="keyword" :showAction="false" @c></u-search> -->
  11. </view>
  12. <view class="inner">
  13. <view class="title-box align-center justify-between">
  14. 已添加指标(按住左侧按钮拖动排序)
  15. </view>
  16. <view class="form-box">
  17. <drag-sorts :listData="listData" :itemHeight="100" :scrollBoxHeight="600" :isAdd="false" @draged="ed"
  18. @itemDisabledClick='onDisabledClick'/>
  19. </view>
  20. <view class="title-box">
  21. 用户自设(长按制除)
  22. </view>
  23. <view class="form-box">
  24. <drag-sorts :showDragCtrl="false" :listData="dataList" :itemHeight="100" :scrollBoxHeight="800"
  25. :isRemove="false" @draged="ed2" @itemAddClick='onAddClick' @itemRemoveClick="onRemove" @navClick='navTo'/>
  26. </view>
  27. </view>
  28. <view class="h20"></view>
  29. <view class="btn-box2">
  30. <view class="sub-btn2" @click="navgetTo(orderStatusValue)">
  31. <image src="/static/images/health/nav_add_icon24.png" class="w48 h48"></image>
  32. <text>新增自定义指标</text>
  33. </view>
  34. <!-- <view class="sub-btn" @click="navgetTo(orderStatusValue)">
  35. <text>保存</text>
  36. </view> -->
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import dragSorts from '@/components/w-drag-sorts/w-drag-sorts.vue'
  42. import {
  43. getPage,
  44. updateIndicator,
  45. deleteIndicator,
  46. listEnabled,
  47. listByReport,
  48. listAllEnabledByReportId,
  49. addResult,
  50. deleteResult
  51. } from '@/api/companyUser.js'
  52. export default {
  53. components: {
  54. dragSorts
  55. },
  56. data() {
  57. return {
  58. curDate: '',
  59. markDays: [],
  60. type: null,
  61. keyword: '',
  62. patientId: null,
  63. famaleurl: "/static/images/health/female_profile.png",
  64. maleurl: "/static/images/health/my_heads.png",
  65. checked: 1,
  66. dataList: [],
  67. listData: [
  68. // {
  69. // id:1,
  70. // icon: '/static/images/苹果.png', //不传该属性,则不显示也不占位
  71. // text: '大血小板比率(P-LCR)'
  72. // },
  73. // {
  74. // id:2,
  75. // icon: '/static/images/雪梨.png',
  76. // text: '血小板体积分布宽度(PDW)'
  77. // },
  78. // {
  79. // id:6,
  80. // icon: '/static/images/橙子.png',
  81. // text: '平均血小板体积(MPV)'
  82. // },
  83. // {
  84. // id:5,
  85. // icon: '/static/images/香蕉.png',
  86. // text: '血小板压积(PCT)'
  87. // },
  88. // {
  89. // id:4,
  90. // icon: '/static/images/香蕉.png',
  91. // text: '血小板压积(PCT)'
  92. // },
  93. // {
  94. // id:3,
  95. // icon: '/static/images/香蕉.png',
  96. // text: '血小板压积(PCT)'
  97. // },
  98. ],
  99. form: {
  100. "abnormalType": "",
  101. "indicatorCateId": 0,
  102. "indicatorId": 0,
  103. "indicatorName": "",
  104. "isAbnormal": 0,
  105. "refRange": "",
  106. "remarks": "",
  107. // "reportId": 0,
  108. // "resultId": 0,
  109. "testResult": "",
  110. // "testValue": 0,
  111. "unitName": "",
  112. },
  113. reportId:null,
  114. };
  115. },
  116. onLoad(options) {
  117. console.log(options,'o')
  118. if(options.id){
  119. this.reportId=options.id
  120. this.listAllEnabledByReportId()
  121. this.listByReport()
  122. }
  123. uni.$on('refreshEditIndicator', () => {
  124. this.listAllEnabledByReportId()
  125. this.listByReport()
  126. // this.getPage()
  127. })
  128. // this.getPage()
  129. },
  130. onShow() {
  131. },
  132. methods: {
  133. doSearch(){
  134. // this.getPage()
  135. },
  136. //日历
  137. onDayClick(data) {
  138. this.curDate = data.date;
  139. },
  140. navgetTo() {
  141. uni.navigateTo({
  142. url: '/pages_user/user/addIndicator?type=add'
  143. })
  144. },
  145. navTo(index,item){
  146. uni.navigateTo({
  147. url: '/pages_user/user/addIndicator?type=edit&id='+item.indicatorId
  148. })
  149. },
  150. listByReport() {
  151. listByReport(this.reportId).then(
  152. res => {
  153. if (res.code == 200) {
  154. this.listData = res.data;
  155. // uni.$emit('refreshInformation');
  156. } else {
  157. uni.showToast({
  158. title: res.msg,
  159. });
  160. }
  161. },
  162. rej => {}
  163. );
  164. },
  165. listAllEnabledByReportId() {
  166. var data={
  167. reportId:this.reportId
  168. }
  169. listAllEnabledByReportId(data).then(
  170. res => {
  171. if (res.code == 200) {
  172. this.dataList = res.data
  173. } else {
  174. uni.showToast({
  175. icon: 'none',
  176. title: res.msg,
  177. });
  178. }
  179. },
  180. rej => {}
  181. );
  182. },
  183. // getPage() {
  184. // var data = {
  185. // indicatorName:this.keyword,
  186. // pageNum: 1,
  187. // pageSize: 100
  188. // }
  189. // getPage(data).then(
  190. // res => {
  191. // if (res.code == 200) {
  192. // this.dataList = res.data.list
  193. // } else {
  194. // uni.showToast({
  195. // icon: 'none',
  196. // title: res.msg,
  197. // });
  198. // }
  199. // },
  200. // rej => {}
  201. // );
  202. // },
  203. //排序后的数组
  204. ed(list) {
  205. if (list) {
  206. this.listData = list
  207. }
  208. },
  209. ed2(list) {
  210. if (list) {
  211. this.listData = list
  212. }
  213. },
  214. onItemIconClick(index, item) {
  215. },
  216. onDisabledClick(index, item) {
  217. this.listData = this.listData.filter(it => it.indicatorId !== item.indicatorId)
  218. this.updateResult(item.resultId)
  219. },
  220. onAddClick(index, item) {
  221. this.dataList = this.dataList.filter(it => it.indicatorId !== item.indicatorId)
  222. // 遍历item的属性,赋值到form(而非遍历form的属性)
  223. // for(var key in this.form){
  224. // this.form[key]=item[key]
  225. // }
  226. const data = {
  227. ...this.form, // 保留表单默认值
  228. indicatorId: item.indicatorId || 0,
  229. indicatorName: item.indicatorName || "",
  230. indicatorCateId: Number(item.indicatorCategory) || 0, // 转换为数字类型
  231. "remarks": "",
  232. unitId: item.unitId,
  233. "abnormalType": "",
  234. // 处理参考范围(合并min和max为refRange)
  235. refRange: item.referenceMin !== null && item.referenceMax !== null ? `${item.referenceMin}-${item.referenceMax}` : (item.referenceText || ""),
  236. // 其他字段保持表单默认值或根据需要映射
  237. isAbnormal: 0, // 异常状态需要根据测量值和参考范围计算
  238. reportId: this.reportId // 添加reportId
  239. };
  240. this.addResult(data)
  241. },
  242. addResult(data) {
  243. addResult(data).then(
  244. res => {
  245. if (res.code == 200) {
  246. uni.showToast({
  247. icon: 'success',
  248. title: "操作成功",
  249. });
  250. // this.getPage();
  251. this.listByReport();
  252. this.listAllEnabledByReportId()
  253. uni.$emit('refreshInformation');
  254. // setTimeout(function() {
  255. // uni.navigateBack({
  256. // delta: 1
  257. // })
  258. // }, 500);
  259. } else {
  260. uni.showToast({
  261. icon: 'none',
  262. title: res.msg,
  263. });
  264. }
  265. },
  266. rej => {}
  267. );
  268. },
  269. updateResult(id) {
  270. deleteResult(id).then(
  271. res => {
  272. if (res.code == 200) {
  273. uni.showToast({
  274. icon: 'success',
  275. title: "操作成功",
  276. });
  277. this.listByReport();
  278. this.listAllEnabledByReportId()
  279. uni.$emit('refreshInformation');
  280. // setTimeout(function() {
  281. // uni.navigateBack({
  282. // delta: 1
  283. // })
  284. // }, 500);
  285. // this.getPage();
  286. } else {
  287. uni.showToast({
  288. icon: 'none',
  289. title: res.msg,
  290. });
  291. }
  292. },
  293. rej => {}
  294. );
  295. },
  296. onRemove(index,item) {
  297. console.log(item,'item')
  298. var that = this
  299. uni.showModal({
  300. title: '提示',
  301. content: '确定删除指标吗',
  302. success: function(res) {
  303. if (res.confirm) {
  304. deleteIndicator(item.indicatorId).then(res => {
  305. if (res.code == 200) {
  306. uni.showToast({
  307. icon: 'success',
  308. title: '删除成功!',
  309. });
  310. // that.listEnabled()
  311. that.listAllEnabledByReportId()
  312. } else {
  313. uni.showToast({
  314. icon: 'none',
  315. title: res.msg,
  316. });
  317. }
  318. });
  319. } else if (res.cancel) {
  320. }
  321. }
  322. });
  323. },
  324. // 出生日期选择
  325. bindDateChange: function(e) {
  326. this.form.birthday = e.target.value
  327. },
  328. }
  329. }
  330. </script>
  331. <style lang="scss">
  332. page {
  333. height: 100%;
  334. background: #F5F7FA;
  335. }
  336. .content {
  337. height: 100%;
  338. display: flex;
  339. flex-direction: column;
  340. justify-content: space-between;
  341. .top-fixed {
  342. position: fixed;
  343. top: 0;
  344. background: #FFFFFF;
  345. padding: 20rpx;
  346. width: 100%;
  347. box-sizing: border-box;
  348. z-index: 999;
  349. }
  350. .search-cont{
  351. // padding: 16upx 30upx;
  352. .inner2{
  353. box-sizing: border-box;
  354. width: 100%;
  355. height: 72upx;
  356. background: #F5F7FA;
  357. border-radius: 36upx;
  358. display: flex;
  359. align-items: center;
  360. padding: 0 30upx;
  361. .icon-search{
  362. width: 28upx;
  363. height: 28upx;
  364. margin-right: 20upx;
  365. }
  366. input{
  367. height: 60upx;
  368. line-height: 60upx;
  369. flex: 1;
  370. }
  371. }
  372. }
  373. .inner {
  374. // height: calc(100% - 120upx);
  375. padding: 0 20upx;
  376. padding-top: 110rpx;
  377. padding-bottom: 200rpx;
  378. .title-box {
  379. font-family: PingFang SC, PingFang SC;
  380. font-weight: 400;
  381. font-size: 24rpx;
  382. color: #898E91;
  383. text-align: left;
  384. padding: 24rpx 0;
  385. .select-box {
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. text {
  390. font-family: PingFang SC;
  391. font-weight: 400;
  392. font-size: 24rpx;
  393. color: #626468;
  394. margin-left: 8rpx;
  395. }
  396. }
  397. .select-box2 {
  398. width: 216rpx;
  399. height: 64rpx;
  400. background: #FFFFFF;
  401. border-radius: 32rpx 32rpx 32rpx 32rpx;
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. text {
  406. font-family: PingFang SC;
  407. font-weight: 400;
  408. font-size: 24rpx;
  409. color: #626468;
  410. margin-left: 5rpx;
  411. }
  412. }
  413. }
  414. .form-box {
  415. // padding: 0 30upx;
  416. background: #FFFFFF;
  417. border-radius: 16upx;
  418. overflow: hidden;
  419. // margin-bottom: 20upx;
  420. .form-title {
  421. font-family: PingFang SC;
  422. font-weight: 500;
  423. font-size: 32rpx;
  424. color: #626468;
  425. text-align: left;
  426. padding: 30rpx 0;
  427. display: block;
  428. }
  429. .form-item {
  430. padding: 30upx 0;
  431. display: flex;
  432. align-items: center;
  433. justify-content: space-between;
  434. border-bottom: 1px solid #F1F1F1;
  435. &:last-child {
  436. border-bottom: none;
  437. }
  438. .left {
  439. display: flex;
  440. flex-direction: column;
  441. align-items: flex-start;
  442. .time {
  443. font-family: PingFang SC;
  444. font-weight: 400;
  445. font-size: 28rpx;
  446. color: #898E91;
  447. text-align: left;
  448. }
  449. }
  450. .check {
  451. display: flex;
  452. align-items: center;
  453. justify-content: center;
  454. text {
  455. // font-family: PingFang SC;
  456. font-weight: 400;
  457. font-size: 24rpx;
  458. color: #008FD3;
  459. margin-left: 16rpx;
  460. }
  461. }
  462. .label {
  463. // width: 150upx;
  464. text-align: left;
  465. font-weight: 500;
  466. font-size: 32rpx;
  467. color: #222426;
  468. text-align: left;
  469. }
  470. .num {
  471. font-family: PingFang SC;
  472. font-weight: 400;
  473. font-size: 32rpx;
  474. color: #222426;
  475. line-height: 34rpx;
  476. display: flex;
  477. align-items: center;
  478. }
  479. }
  480. }
  481. }
  482. .btn-box2 {
  483. z-index: 9999;
  484. width: 100%;
  485. padding: 30upx;
  486. position: fixed;
  487. bottom: 0;
  488. left: 0;
  489. box-sizing: border-box;
  490. background: #FFFFFF;
  491. display: flex;
  492. align-items: center;
  493. justify-content: space-between;
  494. padding-bottom: 40rpx;
  495. .sub-btn {
  496. flex: 1;
  497. // width: 100%;
  498. height: 88upx;
  499. line-height: 88upx;
  500. text-align: center;
  501. font-size: 32upx;
  502. font-family: PingFang SC;
  503. font-weight: bold;
  504. color: #FFFFFF;
  505. background: #008FD3;
  506. border-radius: 44upx;
  507. display: flex;
  508. align-items: center;
  509. border: 2rpx solid #008FD3;
  510. justify-content: center;
  511. }
  512. .sub-btn2 {
  513. flex: auto;
  514. height: 88upx;
  515. line-height: 88upx;
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. text-align: center;
  520. font-size: 32rpx;
  521. color: #fff;
  522. font-family: PingFang SC;
  523. font-weight: bold;
  524. background: #FF5030;
  525. border-radius: 44rpx 44rpx 44rpx 44rpx;
  526. margin-right: 20rpx;
  527. image {
  528. margin-right: 16rpx;
  529. }
  530. }
  531. }
  532. }
  533. </style>