dpTask.vue 13 KB

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