djTask.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view class="djTask">
  3. <!-- 任务进度 -->
  4. <view class="progress_title">
  5. <view class="progress">
  6. <text class="progress_text">任务进度:<text
  7. class="progress_text_1">{{wwcNumber()}}/{{pageData.totalProgress}}</text></text>
  8. </view>
  9. <view class="bhgs">
  10. <text class="bhgs_title">不合格数<text class="bhgs_text">{{bhgNumber()}}</text></text>
  11. </view>
  12. </view>
  13. <!-- 处方编号 -->
  14. <view class="sub_title">
  15. <view class="cfbh">
  16. <text class="cfbh_title">处方编号<text class="cfbh_text">{{pageData.cfbh}}</text></text>
  17. </view>
  18. </view>
  19. <!-- 操作人 -->
  20. <view class="operator" v-if="pageData.operatorName!=null && pageData.operatorName!=''">
  21. <text class="operator_title">操作人<text class="operator_text">{{pageData.operatorName}}</text></text>
  22. </view>
  23. <!-- 查看处方内容按钮 -->
  24. <view class="detail">
  25. <view @click="showDetail" class="showDetail_button">查看处方内容<uni-icons type="calendar"
  26. color="#FFFFFF"></uni-icons></view>
  27. </view>
  28. <!-- 检查结果 -->
  29. <uni-card padding="0" spacing="0" v-for="(item,index) in pageData.resData.results" class="djList">
  30. <view class="djList_title">
  31. <view class="djList_text">检查项目</view>
  32. <view class="djList_righttext">{{item.item}}</view>
  33. </view>
  34. <view class="djList_title">
  35. <view class="djList_text">检查内容</view>
  36. <view class="djList_righttext">{{item.assessmentCriteria}}</view>
  37. </view>
  38. <view class="djList_title">
  39. <view class="djList_text">检查结果</view>
  40. <view :class="item.assessmentResult=='不合格'? 'djList_redtext' : 'djList_righttext'">
  41. {{item.assessmentResult}}
  42. </view>
  43. </view>
  44. <view class="djList_title">
  45. <view class="djList_text">备注</view>
  46. <view class="djList_righttext">
  47. {{item.remark}}
  48. </view>
  49. </view>
  50. <view class="djList_title" v-if="item.resultContent">
  51. <view class="djList_text">原因</view>
  52. <view class="djList_righttext">{{item.resultContent}}</view>
  53. </view>
  54. <view class="button_group" v-if="pageData.operatorStatus=='add' || pageData.taskStatus=='1'">
  55. <view class="bhg_button" @click="bhgCheck(item)">不合格</view>
  56. <view class="hg_button" @click="hgCheck(item)">合格</view>
  57. </view>
  58. </uni-card>
  59. <!-- 图片上传 -->
  60. <view class="image_upload">
  61. <uni-card>
  62. <uni-section title="图片上传" type="line"></uni-section>
  63. <view class="img_upload">
  64. <uni-file-picker limit="4" :modelValue="showImage(pageData.imageList)"
  65. :readonly="pageData.imageStatus" @select="selectImg" @delete="deleteImg"></uni-file-picker>
  66. </view>
  67. </uni-card>
  68. </view>
  69. <!-- 按钮 -->
  70. <view class="operator_button" v-if="pageData.operatorStatus=='add'">
  71. <!-- <button :class="pageData.buttonDisabled==false?'pass_button':'pass_button_grey'" @click="pass" :disabled="pageData.buttonDisabled">一键通过</button>
  72. --> <!-- 如果还有数据按钮显示为“下一个”,数据全部加载完毕显示为“完成” -->
  73. <!-- <view class="finish_button_grop"> -->
  74. <button class="next_or_finish_button_save" @click="save">保存</button>
  75. <!-- </view> -->
  76. <!-- <view class="finish_button_grop"> -->
  77. <button class="next_or_finish_button" @click="next">提交</button>
  78. <!-- </view> -->
  79. </view>
  80. <!-- 任务详情-编辑 -->
  81. <view
  82. v-if="pageData.taskStatusData == '7001' || pageData.taskStatusData == '7002' || pageData.taskStatusData == '7003'">
  83. <view class="operator_button" v-if="pageData.taskStatus=='2' && pageData.taskStatusData!='7004'">
  84. <!-- <button class="pass_button" @click="back">返回</button> -->
  85. <!-- <view class="finish_button_grop"> -->
  86. <button class="next_or_finish_button" @click="editTask()">编辑</button>
  87. <!-- </view> -->
  88. </view>
  89. </view>
  90. <!-- 任务详情-保存 -->
  91. <view class="operator_button" v-if="pageData.taskStatus=='1'">
  92. <button class="next_or_finish_button_save" @click="save">保存</button>
  93. <button class="next_or_finish_button" @click="next">提交</button>
  94. </view>
  95. <!-- 不合格弹出框 -->
  96. <uni-popup ref="bhgDialog" type="dialog">
  97. <uni-popup-dialog type="info" mode="input" confirmText="确定" cancelText="取消" title="原因" value=""
  98. placeholder="请填写原因" @confirm="bhgDialogConfirm" @close="bhgDialogClose">
  99. <uni-easyinput type="textarea" maxlength="50" autoHeight v-model="pageData.reason"
  100. placeholder="请输入原因"></uni-easyinput>
  101. </uni-popup-dialog>
  102. </uni-popup>
  103. <!-- 一键通过弹出框 -->
  104. <uni-popup ref="passDialog" type="dialog">
  105. <view class="passDialog">
  106. <view class="passDialog_title">
  107. <uni-title type="h2" title="一键通过" align="center"></uni-title>
  108. <!-- 倒计时 -->
  109. <smh-countDown second="10" radius="60" lineWidth="3rpx" color="#BFA578"
  110. @end="countDownEnd"></smh-countDown>
  111. </view>
  112. <view class="passDialog_content">
  113. <view>10秒后将自动跳转下一个处方</view>
  114. <view class="passDialog_content_cancel">点击取消可停留本页面</view>
  115. </view>
  116. <view class="passDialog_button">
  117. <view class="passDialog_button_cancel" @click="passCancel">取消</view>
  118. <view class="passDialog_button_confirm" @click="passConfirm">确定</view>
  119. </view>
  120. </view>
  121. </uni-popup>
  122. </view>
  123. </template>
  124. <script setup>
  125. import {
  126. ref,
  127. reactive,
  128. computed
  129. } from "vue";
  130. import {
  131. onLoad,
  132. onShow,
  133. onUnload,
  134. onPullDownRefresh
  135. } from "@dcloudio/uni-app";
  136. import http from '@/utils/request';
  137. import {
  138. uploadImageModelValue
  139. } from '@/pages/controls/image/OssService'
  140. const pageData = reactive({
  141. // 处方编号
  142. cfbh: '',
  143. // 操作人姓名
  144. operatorName: '',
  145. // 操作状态,是编辑/查看
  146. operatorStatus: '',
  147. djList: [],
  148. // 检查项目Id
  149. checkId: '',
  150. // 合格列表
  151. hgList: [],
  152. // 不合格列表
  153. bhgList: [],
  154. // 不合格原因
  155. reason: '',
  156. resData: [],
  157. imageIdList: [],
  158. // 图片列表
  159. imageList: [],
  160. imageStatus: true,
  161. id: '',
  162. totalProgress: 0,
  163. // 任务状态(编辑为2,保存为1)
  164. taskStatus: '',
  165. taskStatusData: '',
  166. buttonDisabled: true,
  167. // 处方信息
  168. detail: {},
  169. // 药品
  170. medicines: []
  171. })
  172. const formData = reactive({
  173. id: '',
  174. pageSize: 1,
  175. pageNum: 10
  176. })
  177. const createData = reactive({
  178. taskId: '',
  179. pId: '',
  180. providerType: ''
  181. })
  182. const saveTaskData = reactive({
  183. detail: '',
  184. unHgStateName: ''
  185. })
  186. // 查看处方内容
  187. const showDetail = () => {
  188. console.log(pageData.detail);
  189. console.log(pageData.medicines);
  190. uni.navigateTo({
  191. url: '/pages/ypczk/zkTask/prescriptionInfo/prescriptionInfo?detail=' + encodeURIComponent(JSON
  192. .stringify(pageData.detail)) + '&medicines=' + encodeURIComponent(JSON.stringify(pageData
  193. .medicines))
  194. })
  195. }
  196. // 不合格数
  197. const bhgNumber = () => {
  198. let number = 0
  199. if (pageData.resData.results != null) {
  200. pageData.resData.results.forEach(item => {
  201. if (item.assessmentResult == '不合格') {
  202. number++
  203. }
  204. })
  205. }
  206. return number
  207. }
  208. // 定义不合格弹出输入框
  209. const bhgDialog = ref()
  210. // 提交不合格原因
  211. const bhgDialogConfirm = () => {
  212. // 获取输入的不合格原因
  213. if (hgTc.value == true) {
  214. if (pageData.reason == null || pageData.reason == '' || pageData.reason == undefined) {
  215. uni.showToast({
  216. title: '请填写原因',
  217. icon: 'error'
  218. });
  219. return
  220. } else {
  221. console.log(item.value);
  222. if (item.value.assessmentResult == "合格" || item.value.assessmentResult == "待检") {
  223. item.value.assessmentResult = "不合格"
  224. item.value.resultContent = pageData.reason
  225. hgTc.value = false
  226. // 打开不合格弹出输入框
  227. if (item.isInput == '1') {
  228. hgTc.value = true
  229. }
  230. bhgDialog._value.open()
  231. }
  232. item.value.resultContent = pageData.reason
  233. pageData.resData.results.forEach((e, idx) => {
  234. if (e.id == item.value.id) {
  235. pageData.resData.results[idx] = item.value
  236. }
  237. })
  238. pageData.reason = ''
  239. bhgDialog._value.close()
  240. item.value = {}
  241. }
  242. } else {
  243. item.value.resultContent = pageData.reason
  244. pageData.resData.results.forEach((e, idx) => {
  245. if (e.id == item.value.id) {
  246. pageData.resData.results[idx] = item.value
  247. }
  248. })
  249. pageData.reason = ''
  250. bhgDialog._value.close()
  251. item.value = {}
  252. }
  253. }
  254. // 任务进度(已完成)
  255. const wwcNumber = () => {
  256. let number = 0
  257. let data = pageData.resData.results
  258. if (data != null) {
  259. for (var i = 0; i < data.length; i++) {
  260. if (data[i].assessmentResult != null && data[i].assessmentResult != undefined && data[i]
  261. .assessmentResult != '待检')
  262. number++;
  263. }
  264. }
  265. return number
  266. }
  267. // 取消不合格弹出输入框
  268. const bhgDialogClose = () => {
  269. // console.log(item.value);
  270. // // 获取输入的不合格原因
  271. // if (hgTc.value == true) {
  272. // uni.showToast({
  273. // title: '需输入内容不能取消',
  274. // icon: 'error',
  275. // });
  276. // return
  277. // } else {
  278. // // 关闭不合格弹出框
  279. // pageData.reason = ''
  280. // bhgDialog._value.close()
  281. // }
  282. pageData.reason = ''
  283. bhgDialog._value.close()
  284. }
  285. // 一键通过弹出框
  286. const passDialog = ref()
  287. // 一键通过弹出框确定事件
  288. const passConfirm = () => {
  289. countTotal()
  290. saveDjTask()
  291. }
  292. // 一键通过弹出框取消事件
  293. const passCancel = () => {
  294. passDialog._value.close()
  295. }
  296. // 一键通过弹出框倒计时接收事件
  297. const countDownEnd = () => {
  298. countTotal()
  299. saveDjTask()
  300. }
  301. // 选中图片,将选中的图片添加列表
  302. const selectImg = (e) => {
  303. if (pageData.imageList == null || pageData.imageList == undefined) {
  304. pageData.imageList = []
  305. }
  306. e.tempFiles.forEach(item => {
  307. uni.showLoading({
  308. title: '图片上传....',
  309. mask: true
  310. });
  311. http.upload("oss/upload", {
  312. file: item.file
  313. }).then(e => {
  314. uni.hideLoading()
  315. pageData.imageList.push(e.id)
  316. })
  317. })
  318. }
  319. // 删除图片,并将其从列表中删除
  320. const deleteImg = (e) => {
  321. let index = 0
  322. pageData.imageList.forEach((item, idx) => {
  323. index = e.tempFilePath.indexOf(item)
  324. if (index > 0) {
  325. // 删除列表中的元素
  326. pageData.imageList.splice(idx, 1)
  327. }
  328. })
  329. }
  330. const item = ref({})
  331. // 不合格
  332. const bhgCheck = (e) => {
  333. item.value = e
  334. hgTc.value = true
  335. bhgDialog._value.open()
  336. // e.score = 0
  337. // if (e.assessmentResult == "合格" || e.assessmentResult == "待检") {
  338. // e.assessmentResult = "不合格"
  339. // item.value = e
  340. // hgTc.value = false
  341. // // 打开不合格弹出输入框
  342. // if (e.isInput == '1') {
  343. // hgTc.value = true
  344. // }
  345. // bhgDialog._value.open()
  346. // }
  347. }
  348. const hgTc = ref(false)
  349. // 合格
  350. const hgCheck = (e) => {
  351. pageData.hgList.push(e.id)
  352. if (e.assessmentResult == '不合格' || e.assessmentResult == '待检') {
  353. e.assessmentResult = '合格'
  354. e.score = e.totalScore
  355. e.resultContent = ''
  356. }
  357. // if (e.isInput == '1') {
  358. // hgTc.value = true
  359. // item.value = e
  360. // // 打开不合格弹出输入框
  361. // bhgDialog._value.open()
  362. // }
  363. }
  364. // 一键通过
  365. const pass = () => {
  366. pageData.resData.results.forEach(item => {
  367. item.assessmentResult = '合格'
  368. item.resultContent = ''
  369. })
  370. passDialog._value.open()
  371. }
  372. // 计算代煎总分
  373. const countTotal = () => {
  374. pageData.resData.resultContent = 0
  375. pageData.resData.results.forEach(item => {
  376. pageData.resData.resultContent += Number(item.score)
  377. })
  378. if (pageData.imageList != null || pageData.imageList != undefined) {
  379. pageData.resData.detail.imageIds = pageData.imageList.toString()
  380. }
  381. }
  382. const saveDjTask = () => {
  383. uni.showLoading({
  384. title: '提交中....',
  385. mask: true
  386. });
  387. http.post("app-api/zkzy/save", pageData.resData).then(res => {
  388. uni.hideLoading()
  389. if (res == true) {
  390. uni.showToast({
  391. title: '提交成功',
  392. success: () => {
  393. uni.navigateBack({
  394. delta: 1
  395. })
  396. }
  397. });
  398. } else {
  399. uni.showToast({
  400. title: '提交失败'
  401. });
  402. }
  403. })
  404. }
  405. //保存
  406. const save = () => {
  407. uni.showLoading({
  408. title: '提交中....',
  409. mask: true
  410. });
  411. if (pageData.imageList != null || pageData.imageList != undefined) {
  412. pageData.resData.detail.imageIds = pageData.imageList.toString()
  413. }
  414. http.post("app-api/zkzy/save", pageData.resData).then(res => {
  415. uni.hideLoading()
  416. if (res == true) {
  417. uni.showToast({
  418. title: '提交成功',
  419. });
  420. } else {
  421. uni.showToast({
  422. title: '提交失败'
  423. });
  424. }
  425. })
  426. }
  427. // 下一个
  428. const next = () => {
  429. if (wwcNumber() == pageData.totalProgress) {
  430. countTotal()
  431. saveDjTask()
  432. } else {
  433. uni.showToast({
  434. title: '提交失败,请检查任务进度',
  435. icon: 'error'
  436. });
  437. }
  438. }
  439. // 完成
  440. const finish = () => {
  441. countTotal()
  442. saveDjTask()
  443. }
  444. // 返回
  445. const back = () => {
  446. uni.navigateBack({
  447. delta: 1
  448. });
  449. }
  450. // 编辑
  451. const editTask = () => {
  452. pageData.imageStatus = !pageData.imageStatus
  453. pageData.taskStatus = '1'
  454. }
  455. // 临时创建代煎代配企业评估任务内容
  456. const createTask = () => {
  457. getTaskId()
  458. http.get("app-api/zkzy/create", createData).then(res => {
  459. if (res == "该处方已质控、不能重复添加") {
  460. uni.showToast({
  461. title: '该处方已质控、不能重复添加',
  462. icon: 'none',
  463. success: () => {
  464. uni.navigateBack({
  465. delta: 1
  466. });
  467. }
  468. });
  469. } else {
  470. getDjTask(res)
  471. }
  472. })
  473. }
  474. // 获取代煎质控作业
  475. const getDjTask = (data) => {
  476. formData.id = data
  477. http.get("app-api/taskDetail/get", formData).then(res => {
  478. pageData.djList = res.results
  479. pageData.cfbh = res.detail.ptwybm
  480. pageData.detail = res.detail
  481. pageData.medicines = res.medicines
  482. saveTaskData.detail = res.results
  483. pageData.resData = res
  484. pageData.djList.forEach(item => {
  485. // 一开始均为“待检状态”
  486. item.assessmentResult = '待检'
  487. })
  488. pageData.totalProgress = res.results.length
  489. if (res.detail.imageIds != null) {
  490. pageData.imageList = showImage(res.detail.imageIds)
  491. }
  492. })
  493. }
  494. // 显示图片
  495. const showImage = (id) => {
  496. return uploadImageModelValue(id)
  497. }
  498. // 获取taskId
  499. const getTaskId = () => {
  500. uni.getStorage({
  501. key: 'saveTaskId',
  502. success: (res) => {
  503. createData.taskId = res.data.taskId
  504. }
  505. })
  506. }
  507. const getDjTaskDetail = () => {
  508. // getTaskId()
  509. http.get("app-api/taskDetail/get", {
  510. id: pageData.id
  511. }).then(res => {
  512. pageData.resData = res
  513. pageData.totalProgress = res.results.length
  514. pageData.taskStatus = 2
  515. pageData.operatorName = res.detail.creatorName
  516. pageData.detail = res.detail
  517. pageData.medicines = res.medicines
  518. res.results.forEach(item => {
  519. // 检查内容(分数与总分相同为合格,反之不合格)
  520. if (item.score == item.totalScore && !item.isDj) {
  521. item.assessmentResult = '合格'
  522. } else {
  523. item.assessmentResult = item.isDj ? '待检' : '不合格'
  524. pageData.bhgNum = pageData.bhgNum + 1
  525. }
  526. })
  527. if (res.detail.imageIds != null && res.detail.imageIds != '') {
  528. if (typeof(res.detail.imageIds) == 'string') {
  529. var urls = res.detail.imageIds.split(',')
  530. pageData.imageList = []
  531. urls.forEach(e => {
  532. pageData.imageList.push(e)
  533. })
  534. }
  535. }
  536. })
  537. }
  538. onShow(() => {
  539. setTimeout(() => {
  540. pageData.buttonDisabled = false
  541. }, 5000)
  542. })
  543. onLoad((type) => {
  544. if (type.state != null) {
  545. pageData.operatorStatus = type.state
  546. }
  547. if (type.cfbh != null) {
  548. pageData.cfbh = type.cfbh
  549. }
  550. if (type.ptwybh != null) {
  551. createData.pId = type.ptwybh
  552. }
  553. if (type.fyfslx != null) {
  554. createData.providerType = type.fyfslx
  555. }
  556. if (type.id != null) {
  557. pageData.id = type.id
  558. }
  559. if (type.taskStatus != null) {
  560. pageData.taskStatusData = type.taskStatus
  561. }
  562. // 获取代煎数据
  563. if (pageData.operatorStatus == 'add') {
  564. pageData.imageStatus = false
  565. createTask()
  566. } else {
  567. pageData.imageStatus = true
  568. getDjTaskDetail()
  569. }
  570. })
  571. </script>
  572. <style lang="scss" scoped>
  573. @import './index.scss'
  574. </style>