editIndicator.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. // setTimeout(function() {
  254. // uni.$emit('refreshEditIndicator');
  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. // this.getPage();
  280. } else {
  281. uni.showToast({
  282. icon: 'none',
  283. title: res.msg,
  284. });
  285. }
  286. },
  287. rej => {}
  288. );
  289. },
  290. onRemove(index,item) {
  291. console.log(item,'item')
  292. var that = this
  293. uni.showModal({
  294. title: '提示',
  295. content: '确定删除指标吗',
  296. success: function(res) {
  297. if (res.confirm) {
  298. deleteIndicator(item.indicatorId).then(res => {
  299. if (res.code == 200) {
  300. uni.showToast({
  301. icon: 'success',
  302. title: '删除成功!',
  303. });
  304. // that.listEnabled()
  305. that.listAllEnabledByReportId()
  306. } else {
  307. uni.showToast({
  308. icon: 'none',
  309. title: res.msg,
  310. });
  311. }
  312. });
  313. } else if (res.cancel) {
  314. }
  315. }
  316. });
  317. },
  318. // 出生日期选择
  319. bindDateChange: function(e) {
  320. this.form.birthday = e.target.value
  321. },
  322. }
  323. }
  324. </script>
  325. <style lang="scss">
  326. page {
  327. height: 100%;
  328. background: #F5F7FA;
  329. }
  330. .content {
  331. height: 100%;
  332. display: flex;
  333. flex-direction: column;
  334. justify-content: space-between;
  335. .top-fixed {
  336. position: fixed;
  337. top: 0;
  338. background: #FFFFFF;
  339. padding: 20rpx;
  340. width: 100%;
  341. box-sizing: border-box;
  342. z-index: 999;
  343. }
  344. .search-cont{
  345. // padding: 16upx 30upx;
  346. .inner2{
  347. box-sizing: border-box;
  348. width: 100%;
  349. height: 72upx;
  350. background: #F5F7FA;
  351. border-radius: 36upx;
  352. display: flex;
  353. align-items: center;
  354. padding: 0 30upx;
  355. .icon-search{
  356. width: 28upx;
  357. height: 28upx;
  358. margin-right: 20upx;
  359. }
  360. input{
  361. height: 60upx;
  362. line-height: 60upx;
  363. flex: 1;
  364. }
  365. }
  366. }
  367. .inner {
  368. // height: calc(100% - 120upx);
  369. padding: 0 20upx;
  370. padding-top: 110rpx;
  371. padding-bottom: 200rpx;
  372. .title-box {
  373. font-family: PingFang SC, PingFang SC;
  374. font-weight: 400;
  375. font-size: 24rpx;
  376. color: #898E91;
  377. text-align: left;
  378. padding: 24rpx 0;
  379. .select-box {
  380. display: flex;
  381. align-items: center;
  382. justify-content: center;
  383. text {
  384. font-family: PingFang SC;
  385. font-weight: 400;
  386. font-size: 24rpx;
  387. color: #626468;
  388. margin-left: 8rpx;
  389. }
  390. }
  391. .select-box2 {
  392. width: 216rpx;
  393. height: 64rpx;
  394. background: #FFFFFF;
  395. border-radius: 32rpx 32rpx 32rpx 32rpx;
  396. display: flex;
  397. align-items: center;
  398. justify-content: center;
  399. text {
  400. font-family: PingFang SC;
  401. font-weight: 400;
  402. font-size: 24rpx;
  403. color: #626468;
  404. margin-left: 5rpx;
  405. }
  406. }
  407. }
  408. .form-box {
  409. // padding: 0 30upx;
  410. background: #FFFFFF;
  411. border-radius: 16upx;
  412. overflow: hidden;
  413. // margin-bottom: 20upx;
  414. .form-title {
  415. font-family: PingFang SC;
  416. font-weight: 500;
  417. font-size: 32rpx;
  418. color: #626468;
  419. text-align: left;
  420. padding: 30rpx 0;
  421. display: block;
  422. }
  423. .form-item {
  424. padding: 30upx 0;
  425. display: flex;
  426. align-items: center;
  427. justify-content: space-between;
  428. border-bottom: 1px solid #F1F1F1;
  429. &:last-child {
  430. border-bottom: none;
  431. }
  432. .left {
  433. display: flex;
  434. flex-direction: column;
  435. align-items: flex-start;
  436. .time {
  437. font-family: PingFang SC;
  438. font-weight: 400;
  439. font-size: 28rpx;
  440. color: #898E91;
  441. text-align: left;
  442. }
  443. }
  444. .check {
  445. display: flex;
  446. align-items: center;
  447. justify-content: center;
  448. text {
  449. // font-family: PingFang SC;
  450. font-weight: 400;
  451. font-size: 24rpx;
  452. color: #008FD3;
  453. margin-left: 16rpx;
  454. }
  455. }
  456. .label {
  457. // width: 150upx;
  458. text-align: left;
  459. font-weight: 500;
  460. font-size: 32rpx;
  461. color: #222426;
  462. text-align: left;
  463. }
  464. .num {
  465. font-family: PingFang SC;
  466. font-weight: 400;
  467. font-size: 32rpx;
  468. color: #222426;
  469. line-height: 34rpx;
  470. display: flex;
  471. align-items: center;
  472. }
  473. }
  474. }
  475. }
  476. .btn-box2 {
  477. z-index: 9999;
  478. width: 100%;
  479. padding: 30upx;
  480. position: fixed;
  481. bottom: 0;
  482. left: 0;
  483. box-sizing: border-box;
  484. background: #FFFFFF;
  485. display: flex;
  486. align-items: center;
  487. justify-content: space-between;
  488. padding-bottom: 40rpx;
  489. .sub-btn {
  490. flex: 1;
  491. // width: 100%;
  492. height: 88upx;
  493. line-height: 88upx;
  494. text-align: center;
  495. font-size: 32upx;
  496. font-family: PingFang SC;
  497. font-weight: bold;
  498. color: #FFFFFF;
  499. background: #008FD3;
  500. border-radius: 44upx;
  501. display: flex;
  502. align-items: center;
  503. border: 2rpx solid #008FD3;
  504. justify-content: center;
  505. }
  506. .sub-btn2 {
  507. flex: auto;
  508. height: 88upx;
  509. line-height: 88upx;
  510. display: flex;
  511. align-items: center;
  512. justify-content: center;
  513. text-align: center;
  514. font-size: 32rpx;
  515. color: #fff;
  516. font-family: PingFang SC;
  517. font-weight: bold;
  518. background: #FF5030;
  519. border-radius: 44rpx 44rpx 44rpx 44rpx;
  520. margin-right: 20rpx;
  521. image {
  522. margin-right: 16rpx;
  523. }
  524. }
  525. }
  526. }
  527. </style>