dpTask.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. console.log();
  174. // return (num/pageData.dpList.length).toFixed(2)
  175. if(avgYz()!=0){
  176. let pjz = (Math.abs(avgYz()-avgSz()) / avgYz())
  177. pjz = (pjz * 100).toFixed(2)
  178. return pjz
  179. }else{
  180. return 0
  181. }
  182. }
  183. // 选中图片,将选中的图片添加列表
  184. const selectImg=(e)=>{
  185. if(pageData.imageList==null || pageData.imageList == undefined){
  186. pageData.imageList=[]
  187. }
  188. e.tempFiles.forEach(item=>{
  189. uni.showLoading({
  190. title: '图片上传....',
  191. mask: true
  192. });
  193. http.upload("oss/upload",{file:item.file}).then(e => {
  194. uni.hideLoading()
  195. pageData.imageList.push(e.id)
  196. })
  197. })
  198. }
  199. // 删除图片,并将其从列表中删除
  200. const deleteImg=(e)=>{
  201. let index=0
  202. pageData.imageList.forEach((item,idx)=>{
  203. index=e.tempFilePath.indexOf(item)
  204. if(index>0){
  205. // 删除列表中的元素
  206. pageData.imageList.splice(idx,1)
  207. }
  208. })
  209. }
  210. const countResultContent=()=>{
  211. pageData.resData.resultContent=0
  212. pageData.resData.resultContent=avgWc()
  213. pageData.resData.detail.reciper=data.reciper
  214. if(pageData.imageList!=null || pageData.imageList!=undefined){
  215. pageData.resData.detail.imageIds=pageData.imageList.toString()
  216. }
  217. }
  218. //保存
  219. const saveTask=()=>{
  220. uni.showLoading({
  221. title: '提交中....',
  222. mask: true
  223. });
  224. http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  225. uni.hideLoading()
  226. if(res==true){
  227. uni.showToast({
  228. title: '已提交',
  229. icon:'success',
  230. });
  231. }else{
  232. uni.showToast({
  233. title: '提交失败',
  234. icon:'fail'
  235. });
  236. }
  237. })
  238. }
  239. // 下一个
  240. const finishTask=()=>{
  241. if(pageData.dpList[0].totalScore=="0"){
  242. uni.showToast({
  243. title: '应重不能为0',
  244. icon:'error'
  245. });
  246. }else if(wwcNumber()!=pageData.totalProgress){
  247. uni.showToast({
  248. title: '提交失败,请检查任务进度',
  249. icon:'error'
  250. });
  251. }else{
  252. countResultContent()
  253. uni.showLoading({
  254. title: '提交中....',
  255. mask: true
  256. });
  257. http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  258. uni.hideLoading()
  259. if(res==true){
  260. uni.showToast({
  261. title: '已提交',
  262. icon:'success',
  263. success: () => {
  264. uni.navigateBack({
  265. delta:1
  266. })
  267. }
  268. });
  269. }else{
  270. uni.showToast({
  271. title: '提交失败',
  272. icon:'fail'
  273. });
  274. }
  275. })
  276. }
  277. // if(pageData.dpList[0].totalScore!="0" && wwcNumber()==pageData.totalProgress){
  278. // countResultContent()
  279. // uni.showLoading({
  280. // title: '提交中....',
  281. // mask: true
  282. // });
  283. // http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  284. // uni.hideLoading()
  285. // if(res==true){
  286. // uni.showToast({
  287. // title: '已提交',
  288. // icon:'success',
  289. // success: () => {
  290. // uni.navigateBack({
  291. // delta:1
  292. // })
  293. // }
  294. // });
  295. // }else{
  296. // uni.showToast({
  297. // title: '提交失败',
  298. // icon:'fail'
  299. // });
  300. // }
  301. // })
  302. // }else{
  303. // uni.showToast({
  304. // title: '提交失败,请检查任务进度',
  305. // icon:'error'
  306. // });
  307. // }
  308. }
  309. // 编辑
  310. const editTask=()=>{
  311. pageData.disabledStatus=!pageData.disabledStatus
  312. pageData.imageStatus=!pageData.imageStatus
  313. pageData.taskStatus='1'
  314. }
  315. // 临时创建代配代配企业评估任务内容
  316. const createTask=()=>{
  317. getTaskId()
  318. http.get("app-api/zkzy/create",createData).then(res=>{
  319. if(res=="该处方已质控、不能重复添加"){
  320. uni.showToast({
  321. title: '该处方已质控、不能重复添加',
  322. icon:'none',
  323. success: () => {
  324. uni.navigateBack({
  325. delta: 1
  326. });
  327. }
  328. });
  329. }else{
  330. getDpTask(res)
  331. }
  332. })
  333. }
  334. // 获取代配质控作业
  335. const getDpTask=(data)=>{
  336. formData.id=data
  337. uni.showLoading({
  338. title: '',
  339. mask: true
  340. });
  341. http.get("app-api/taskDetail/get",formData).then(res=>{
  342. uni.hideLoading()
  343. pageData.dpList = res.results
  344. // 实重、误差初始化赋值
  345. if(pageData.dpList.length!=0){
  346. pageData.dpList.forEach(item=>{
  347. if(item.score==null){
  348. item.score=0
  349. }
  350. if(item.resultContent==null){
  351. item.resultContent=0
  352. }
  353. })
  354. }
  355. pageData.resData=res
  356. pageData.totalProgress=res.results.length
  357. if(res.detail.imageIds!=null){
  358. pageData.imageList=showImage(res.detail.imageIds)
  359. }
  360. })
  361. }
  362. // 显示图片
  363. const showImage=(id)=>{
  364. return uploadImageModelValue(id)
  365. }
  366. // 任务进度(已完成)
  367. const wwcNumber = () =>{
  368. let number = 0
  369. let data = pageData.resData.results
  370. if(data != null){
  371. for (var i = 0; i < data.length; i++) {
  372. if (data[i].score != null && data[i].score != undefined && data[i].score != '')
  373. number ++;
  374. }
  375. }
  376. return number
  377. }
  378. // 不合格数
  379. const bhgNumber=()=>{
  380. let number=0
  381. if(pageData.resData.results!=null){
  382. pageData.resData.results.forEach(item=>{
  383. if (item.resultContent > 5){
  384. number++
  385. }
  386. // if(item.score<item.totalScore){
  387. // number++
  388. // }
  389. })
  390. }
  391. return number
  392. }
  393. // 获取taskId
  394. const getTaskId=()=>{
  395. uni.getStorage({
  396. key:'saveTaskId',
  397. success: (res) => {
  398. createData.taskId = res.data.taskId
  399. }
  400. })
  401. }
  402. const getDpTaskDetail=()=>{
  403. uni.showLoading({
  404. title: '',
  405. mask: true
  406. });
  407. http.get("app-api/taskDetail/get",{id:pageData.id}).then(res=>{
  408. uni.hideLoading()
  409. pageData.resData=res
  410. pageData.dpList = res.results
  411. pageData.totalProgress=res.results.length
  412. pageData.taskStatus=res.detail.status
  413. pageData.operatorName=res.detail.creatorName
  414. data.reciper=res.detail.reciper
  415. if(res.detail.imageIds!=null && res.detail.imageIds!=''){
  416. if(typeof(res.detail.imageIds)=='string'){
  417. var urls=res.detail.imageIds.split(',')
  418. pageData.imageList=[]
  419. urls.forEach(e=>{
  420. pageData.imageList.push(e)
  421. })
  422. }
  423. }
  424. })
  425. }
  426. onLoad((type)=>{
  427. if(type.state!=null){
  428. pageData.operatorStatus=type.state
  429. }
  430. if(type.cfbh!=null){
  431. pageData.cfbh=type.cfbh
  432. }
  433. if(type.ptwybh!=null){
  434. createData.pId=type.ptwybh
  435. pageData.cfbh=type.ptwybh
  436. }
  437. if(type.fyfslx!=null){
  438. createData.providerType=type.fyfslx
  439. }
  440. if(type.id!=null){
  441. pageData.id=type.id
  442. }
  443. if(type.taskStatus!=null){
  444. pageData.taskStatusData=type.taskStatus
  445. }
  446. // 获取代配数据
  447. if(pageData.operatorStatus=='add'){
  448. pageData.imageStatus=false
  449. pageData.disabledStatus=false
  450. createTask()
  451. }else{
  452. pageData.imageStatus=true
  453. pageData.disabledStatus=true
  454. getDpTaskDetail()
  455. }
  456. })
  457. </script>
  458. <style lang="scss" scoped>
  459. @import 'index.scss';
  460. </style>