dpTask.vue 9.8 KB

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