dpTask.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="dpTask">
  3. <uni-card class="progress_card">
  4. <view class="dp_list">
  5. <text style="font-size: 17px; color: rgba(51, 51, 51, 1);">任务进度:<text style="color: rgba(190, 163, 117, 1);">{{wwcNumber()}}/{{pageData.totalProgress}}</text></text>
  6. <view class="bhgs">
  7. <text class="bhgs_title">不合格数<text class="bhgs_text">{{bhgNumber()}}</text></text>
  8. </view>
  9. </view>
  10. <view class="sub_title">
  11. <view class="cfbh">
  12. <text class="cfbh_title">处方编号<text class="cfbh_text">{{pageData.cfbh}}</text></text>
  13. </view>
  14. </view>
  15. <view class="send">
  16. <uni-forms-item label="配方员" name="id" labelWidth="60px">
  17. <uni-easyinput v-model="data.reciper" type="" placeholder="请输入配方员姓名" :inputBorder="false" :disabled="pageData.disabledStatus"/>
  18. </uni-forms-item>
  19. </view>
  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. <uni-table class="dp_table">
  24. <!-- 表头行 -->
  25. <uni-tr>
  26. <uni-th align="center" width="100rpx">贴序</uni-th>
  27. <uni-th align="center" width="150rpx">应重(克)</uni-th>
  28. <uni-th align="center" width="150rpx">实重(克)</uni-th>
  29. <uni-th align="center" width="150rpx">误差(%)</uni-th>
  30. </uni-tr>
  31. <!-- 表格数据行 -->
  32. <uni-tr v-for="(item, index) in pageData.dpList" :key="index">
  33. <uni-td align="center">
  34. <uni-easyinput v-model="item.item" :clearable="false" :disabled="true"></uni-easyinput>
  35. </uni-td>
  36. <uni-td align="center" style="width: 200rpx;">
  37. <view style="display: flex;align-items: center;">
  38. <span v-if="index==0? true : false">
  39. <uni-easyinput v-model.number="item.totalScore" :clearable="false" :disabled="pageData.disabledStatus" type="digit" @change="changeYz(item)"></uni-easyinput>
  40. </span>
  41. <span v-else>
  42. {{item.totalScore}}
  43. </span>
  44. <!-- <text>{{"(>"+(item.score!=null?item.score:0)+"g)"}}</text> -->
  45. </view>
  46. </uni-td>
  47. <uni-td align="center">
  48. <uni-easyinput v-model.number="item.score" :clearable="false" :disabled="pageData.disabledStatus" type="digit" @change="changeSz(item)"></uni-easyinput>
  49. </uni-td>
  50. <uni-td align="center">
  51. <uni-easyinput v-model.number="item.resultContent" :clearable="false" :disabled="pageData.disabledStatus" type="digit"></uni-easyinput>
  52. </uni-td>
  53. </uni-tr>
  54. <!-- 均值 -->
  55. <uni-tr>
  56. <uni-td align="center">总值</uni-td>
  57. <uni-td align="center">{{avgYz()}}</uni-td>
  58. <uni-td align="center">{{avgSz()}}</uni-td>
  59. <uni-td align="center">{{avgWc() +"%"}}</uni-td>
  60. </uni-tr>
  61. </uni-table>
  62. </uni-card>
  63. <view class="dpTask_img">
  64. <uni-card>
  65. <uni-section title="图片上传" type="line">
  66. </uni-section>
  67. <view class="image_upload" style="border-top: 0.5px solid #ebedf0;margin-bottom: 3px;">
  68. <uni-file-picker limit="4" :modelValue="showImage(pageData.imageList)" :readonly="pageData.imageStatus" @select="selectImg" @delete="deleteImg"></uni-file-picker>
  69. </view>
  70. </uni-card>
  71. </view>
  72. <!-- 下一个 -->
  73. <view class="finish_button" v-if="pageData.operatorStatus=='add'">
  74. <button class="button" @click="finishTask()">下一个</button>
  75. </view>
  76. <view v-if="pageData.taskStatusData == '7001' || pageData.taskStatusData == '7002' || pageData.taskStatusData == '7003'">
  77. <!-- 任务详情-编辑 -->
  78. <view class="finish_button" v-if="pageData.taskStatus=='2' && pageData.taskStatusData!='7004'">
  79. <button class="button" @click="editTask()">编辑</button>
  80. </view>
  81. <!-- 任务详情-保存 -->
  82. <view class="finish_button" v-if="pageData.taskStatus=='1'">
  83. <button class="button" @click="finishTask()">保存</button>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script setup>
  89. import {reactive,onMounted,ref,watch,defineComponent, computed} from 'vue';
  90. import {onLoad,onShow,onUnload,onPullDownRefresh} from "@dcloudio/uni-app";
  91. import http from '@/utils/request';
  92. import {uploadImageModelValue} from '@/pages/controls/image/OssService'
  93. const data = reactive({
  94. reciper: ''
  95. })
  96. const pageData = reactive({
  97. // 操作人姓名
  98. operatorName:'',
  99. operatorStatus:'',
  100. cfbh:'',
  101. detailList: [],
  102. dpList:[],
  103. // 图片列表
  104. imageList: [],
  105. // 图片状态
  106. imageStatus:true,
  107. resData:{},
  108. id:'',
  109. // 总任务进度
  110. totalProgress:0,
  111. // 控件状态
  112. disabledStatus:false,
  113. // 任务状态(编辑为2,保存为1)
  114. taskStatus:'',
  115. // 任务状态
  116. taskStatusData:''
  117. })
  118. const formData=reactive({
  119. id:''
  120. })
  121. // 临时创建代煎代配企业评估任务内容 入参
  122. const createData=reactive({
  123. taskId:'',
  124. pId:'',
  125. providerType:''
  126. })
  127. const changeSz=(item)=>{
  128. if(item.score!=null && item.totalScore!=null){
  129. // 误差率 = (实重 - 应重) / 应重*100%
  130. item.resultContent=Math.abs(((item.score-item.totalScore)/item.totalScore).toFixed(2)*100)
  131. }
  132. }
  133. const changeYz=(item)=>{
  134. if(item.totalScore!="0" || item.totalScore!=0){
  135. if(item.score!=null && item.totalScore!=null){
  136. // 误差率 = (实重 - 应重) / 应重*100%
  137. item.resultContent=Math.abs(((item.score-item.totalScore)/item.totalScore).toFixed(2)*100)
  138. }
  139. }else{
  140. uni.showToast({
  141. title: '应重不能为0,请重新输入',
  142. icon:'error'
  143. });
  144. }
  145. for(let i=1;i<pageData.dpList.length;i++){
  146. pageData.dpList[i].totalScore=item.totalScore
  147. }
  148. }
  149. // 均值 应重 保留两位小数
  150. const avgYz=()=>{
  151. let num=0
  152. pageData.dpList.forEach((item,index)=>{
  153. num+=Number(item.totalScore)
  154. })
  155. return num.toFixed(2);
  156. // return (num/pageData.dpList.length).toFixed(2)
  157. }
  158. // 均值 实重 保留两位小数
  159. const avgSz=()=>{
  160. let num=0
  161. pageData.dpList.forEach((item,index)=>{
  162. num+=Number(item.score)
  163. })
  164. // return (num/pageData.dpList.length).toFixed(2)
  165. return num.toFixed(2);
  166. }
  167. // 均值 误差
  168. const avgWc=()=>{
  169. let num=0
  170. pageData.dpList.forEach((item,index)=>{
  171. num+=Number(item.resultContent)
  172. })
  173. // return (num/pageData.dpList.length).toFixed(2)
  174. if(avgYz()!=0){
  175. return (Math.abs(avgYz()-avgSz()) /avgYz()).toFixed(2)*100
  176. }else{
  177. return 0
  178. }
  179. }
  180. // 选中图片,将选中的图片添加列表
  181. const selectImg=(e)=>{
  182. if(pageData.imageList==null || pageData.imageList == undefined){
  183. pageData.imageList=[]
  184. }
  185. e.tempFiles.forEach(item=>{
  186. uni.showLoading({
  187. title: '图片上传....',
  188. mask: true
  189. });
  190. http.upload("oss/upload",{file:item.file}).then(e => {
  191. uni.hideLoading()
  192. pageData.imageList.push(e.id)
  193. })
  194. })
  195. }
  196. // 删除图片,并将其从列表中删除
  197. const deleteImg=(e)=>{
  198. let index=0
  199. pageData.imageList.forEach((item,idx)=>{
  200. index=e.tempFilePath.indexOf(item)
  201. if(index>0){
  202. // 删除列表中的元素
  203. pageData.imageList.splice(idx,1)
  204. }
  205. })
  206. }
  207. const countResultContent=()=>{
  208. pageData.resData.resultContent=0
  209. pageData.resData.resultContent=avgWc()
  210. pageData.resData.detail.reciper=data.reciper
  211. if(pageData.imageList!=null || pageData.imageList!=undefined){
  212. pageData.resData.detail.imageIds=pageData.imageList.toString()
  213. }
  214. }
  215. //保存
  216. const saveTask=()=>{
  217. uni.showLoading({
  218. title: '提交中....',
  219. mask: true
  220. });
  221. http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  222. uni.hideLoading()
  223. if(res==true){
  224. uni.showToast({
  225. title: '已提交',
  226. icon:'success',
  227. });
  228. }else{
  229. uni.showToast({
  230. title: '提交失败',
  231. icon:'fail'
  232. });
  233. }
  234. })
  235. }
  236. // 下一个
  237. const finishTask=()=>{
  238. if(pageData.dpList[0].totalScore=="0"){
  239. uni.showToast({
  240. title: '应重不能为0',
  241. icon:'error'
  242. });
  243. }else if(wwcNumber()!=pageData.totalProgress){
  244. uni.showToast({
  245. title: '提交失败,请检查任务进度',
  246. icon:'error'
  247. });
  248. }else{
  249. countResultContent()
  250. uni.showLoading({
  251. title: '提交中....',
  252. mask: true
  253. });
  254. http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  255. uni.hideLoading()
  256. if(res==true){
  257. uni.showToast({
  258. title: '已提交',
  259. icon:'success',
  260. success: () => {
  261. uni.navigateBack({
  262. delta:1
  263. })
  264. }
  265. });
  266. }else{
  267. uni.showToast({
  268. title: '提交失败',
  269. icon:'fail'
  270. });
  271. }
  272. })
  273. }
  274. // if(pageData.dpList[0].totalScore!="0" && wwcNumber()==pageData.totalProgress){
  275. // countResultContent()
  276. // uni.showLoading({
  277. // title: '提交中....',
  278. // mask: true
  279. // });
  280. // http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  281. // uni.hideLoading()
  282. // if(res==true){
  283. // uni.showToast({
  284. // title: '已提交',
  285. // icon:'success',
  286. // success: () => {
  287. // uni.navigateBack({
  288. // delta:1
  289. // })
  290. // }
  291. // });
  292. // }else{
  293. // uni.showToast({
  294. // title: '提交失败',
  295. // icon:'fail'
  296. // });
  297. // }
  298. // })
  299. // }else{
  300. // uni.showToast({
  301. // title: '提交失败,请检查任务进度',
  302. // icon:'error'
  303. // });
  304. // }
  305. }
  306. // 编辑
  307. const editTask=()=>{
  308. pageData.disabledStatus=!pageData.disabledStatus
  309. pageData.imageStatus=!pageData.imageStatus
  310. pageData.taskStatus='1'
  311. }
  312. // 临时创建代配代配企业评估任务内容
  313. const createTask=()=>{
  314. getTaskId()
  315. http.get("app-api/zkzy/create",createData).then(res=>{
  316. if(res=="该处方已质控、不能重复添加"){
  317. uni.showToast({
  318. title: '该处方已质控、不能重复添加',
  319. icon:'none',
  320. success: () => {
  321. uni.navigateBack({
  322. delta: 1
  323. });
  324. }
  325. });
  326. }else{
  327. getDpTask(res)
  328. }
  329. })
  330. }
  331. // 获取代配质控作业
  332. const getDpTask=(data)=>{
  333. formData.id=data
  334. uni.showLoading({
  335. title: '',
  336. mask: true
  337. });
  338. http.get("app-api/taskDetail/get",formData).then(res=>{
  339. uni.hideLoading()
  340. pageData.dpList = res.results
  341. // 实重、误差初始化赋值
  342. if(pageData.dpList.length!=0){
  343. pageData.dpList.forEach(item=>{
  344. if(item.score==null){
  345. item.score=0
  346. }
  347. if(item.resultContent==null){
  348. item.resultContent=0
  349. }
  350. })
  351. }
  352. pageData.resData=res
  353. pageData.totalProgress=res.results.length
  354. if(res.detail.imageIds!=null){
  355. pageData.imageList=showImage(res.detail.imageIds)
  356. }
  357. })
  358. }
  359. // 显示图片
  360. const showImage=(id)=>{
  361. return uploadImageModelValue(id)
  362. }
  363. // 任务进度(已完成)
  364. const wwcNumber = () =>{
  365. let number = 0
  366. let data = pageData.resData.results
  367. if(data != null){
  368. for (var i = 0; i < data.length; i++) {
  369. if (data[i].score != null && data[i].score != undefined && data[i].score != '')
  370. number ++;
  371. }
  372. }
  373. return number
  374. }
  375. // 不合格数
  376. const bhgNumber=()=>{
  377. let number=0
  378. if(pageData.resData.results!=null){
  379. pageData.resData.results.forEach(item=>{
  380. if(item.score<item.totalScore){
  381. number++
  382. }
  383. })
  384. }
  385. return number
  386. }
  387. // 获取taskId
  388. const getTaskId=()=>{
  389. uni.getStorage({
  390. key:'saveTaskId',
  391. success: (res) => {
  392. createData.taskId = res.data.taskId
  393. }
  394. })
  395. }
  396. const getDpTaskDetail=()=>{
  397. uni.showLoading({
  398. title: '',
  399. mask: true
  400. });
  401. http.get("app-api/taskDetail/get",{id:pageData.id}).then(res=>{
  402. uni.hideLoading()
  403. pageData.resData=res
  404. pageData.dpList = res.results
  405. pageData.totalProgress=res.results.length
  406. pageData.taskStatus=res.detail.status
  407. pageData.operatorName=res.detail.creatorName
  408. data.reciper=res.detail.reciper
  409. if(res.detail.imageIds!=null && res.detail.imageIds!=''){
  410. if(typeof(res.detail.imageIds)=='string'){
  411. var urls=res.detail.imageIds.split(',')
  412. pageData.imageList=[]
  413. urls.forEach(e=>{
  414. pageData.imageList.push(e)
  415. })
  416. }
  417. }
  418. })
  419. }
  420. onLoad((type)=>{
  421. if(type.state!=null){
  422. pageData.operatorStatus=type.state
  423. }
  424. if(type.cfbh!=null){
  425. pageData.cfbh=type.cfbh
  426. }
  427. if(type.ptwybh!=null){
  428. createData.pId=type.ptwybh
  429. pageData.cfbh=type.ptwybh
  430. }
  431. if(type.fyfslx!=null){
  432. createData.providerType=type.fyfslx
  433. }
  434. if(type.id!=null){
  435. pageData.id=type.id
  436. }
  437. if(type.taskStatus!=null){
  438. pageData.taskStatusData=type.taskStatus
  439. }
  440. // 获取代配数据
  441. if(pageData.operatorStatus=='add'){
  442. pageData.imageStatus=false
  443. pageData.disabledStatus=false
  444. createTask()
  445. }else{
  446. pageData.imageStatus=true
  447. pageData.disabledStatus=true
  448. getDpTaskDetail()
  449. }
  450. })
  451. </script>
  452. <style lang="scss" scoped>
  453. @import 'index.scss';
  454. </style>