dpTask.vue 11 KB

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