dpTask.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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="item.totalScore" :clearable="false" :disabled="pageData.disabledStatus" type="digit"></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="item.score" :clearable="false" :disabled="pageData.disabledStatus" type="digit"></uni-easyinput>
  42. </uni-td>
  43. <uni-td align="center">
  44. <uni-easyinput v-model="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="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. </view>
  70. </template>
  71. <script setup>
  72. import {reactive,onMounted,ref,watch,defineComponent, computed} from 'vue';
  73. import {onLoad,onShow,onUnload,onPullDownRefresh} from "@dcloudio/uni-app";
  74. import http from '@/utils/request';
  75. import {uploadImageModelValue} from '@/pages/controls/image/OssService'
  76. const data = reactive({
  77. reciper: ''
  78. })
  79. const pageData = reactive({
  80. operatorStatus:'',
  81. cfbh:'',
  82. detailList: [],
  83. dpList:[],
  84. // 图片列表
  85. imageList: [],
  86. imageIdList:[],
  87. // 图片状态
  88. imageStatus:true,
  89. resData:{},
  90. id:'',
  91. // 总任务进度
  92. totalProgress:0,
  93. // 输入框状态
  94. disabledStatus:false
  95. })
  96. const formData=reactive({
  97. id:''
  98. })
  99. // 临时创建代煎代配企业评估任务内容 入参
  100. const createData=reactive({
  101. taskId:'',
  102. pId:'',
  103. providerType:''
  104. })
  105. // 均值 应重
  106. const avgYz=()=>{
  107. let num=0
  108. pageData.dpList.forEach((item,index)=>{
  109. num+=Number(item.totalScore)
  110. })
  111. return (num/pageData.dpList.length).toFixed(2)
  112. }
  113. // 均值 实重
  114. const avgSz=()=>{
  115. let num=0
  116. pageData.dpList.forEach((item,index)=>{
  117. num+=Number(item.score)
  118. })
  119. return (num/pageData.dpList.length).toFixed(2)
  120. }
  121. // 均值 误差
  122. const avgWc=()=>{
  123. let num=0
  124. pageData.dpList.forEach((item,index)=>{
  125. num+=Number(item.resultContent)
  126. })
  127. return (num/pageData.dpList.length).toFixed(2)
  128. }
  129. // 选中图片,将选中的图片添加列表
  130. const selectImg=(e)=>{
  131. console.log(e)
  132. e.tempFiles.forEach(item=>{
  133. uni.showLoading({
  134. title: '图片上传....',
  135. mask: true
  136. });
  137. http.upload("oss/upload",{file:item.file}).then(e => {
  138. uni.hideLoading()
  139. item.id = e.id
  140. console.log(e.id);
  141. pageData.resData.detail.imageIds=[]
  142. pageData.imageIdList.push(e.id)
  143. pageData.resData.detail.imageIds=pageData.imageIdList.toString()
  144. pageData.imageList.push(item)
  145. })
  146. })
  147. }
  148. // 删除图片,并将其从列表中删除
  149. const deleteImg=(e)=>{
  150. console.log(e)
  151. let index=0
  152. index = pageData.imageList.indexOf(e.tempFilePaths)
  153. pageData.imageList.splice(index,1)
  154. pageData.imageIdList.splice(index,1)
  155. pageData.resData.detail.imageIds=pageData.imageIdList.toString()
  156. }
  157. const countResultContent=()=>{
  158. pageData.resData.resultContent=0
  159. pageData.resData.resultContent=avgWc()
  160. console.log(pageData.resData.resultContent);
  161. pageData.resData.detail.reciper=data.reciper
  162. }
  163. // 下一个
  164. const finishTask=()=>{
  165. countResultContent()
  166. uni.showLoading({
  167. title: '提交中....',
  168. mask: true
  169. });
  170. http.post("app-api/zkzy/save",pageData.resData).then(res=>{
  171. uni.hideLoading()
  172. if(res==true){
  173. uni.showToast({
  174. title: '已提交',
  175. icon:'success',
  176. success: () => {
  177. uni.navigateBack({
  178. delta:1
  179. })
  180. }
  181. });
  182. }else{
  183. uni.showToast({
  184. title: '提交失败',
  185. icon:'fail'
  186. });
  187. }
  188. })
  189. }
  190. // 临时创建代配代配企业评估任务内容
  191. const createTask=()=>{
  192. getTaskId()
  193. http.get("app-api/zkzy/create",createData).then(res=>{
  194. getDpTask(res)
  195. })
  196. }
  197. // 获取代配质控作业
  198. const getDpTask=(data)=>{
  199. formData.id=data
  200. http.get("app-api/taskDetail/get",formData).then(res=>{
  201. console.log(res)
  202. pageData.dpList = res.results
  203. pageData.resData=res
  204. pageData.totalProgress=res.results.length
  205. if(res.detail.imageIds!=null){
  206. pageData.imageList=showImage(res.detail.imageIds)
  207. }
  208. })
  209. }
  210. // 显示图片
  211. const showImage=(id)=>{
  212. return uploadImageModelValue(id)
  213. }
  214. // 任务进度(已完成)
  215. const wwcNumber = () =>{
  216. let number = 0
  217. let data = pageData.resData.results
  218. if(data != null){
  219. for (var i = 0; i < data.length; i++) {
  220. if (data[i].score != null && data[i].score != undefined && data[i].score != '')
  221. number ++;
  222. }
  223. }
  224. return number
  225. }
  226. // 不合格数
  227. const bhgNumber=()=>{
  228. let number=0
  229. if(pageData.resData.results!=null){
  230. pageData.resData.results.forEach(item=>{
  231. if(item.score<item.totalScore){
  232. number++
  233. }
  234. })
  235. }
  236. return number
  237. }
  238. // 获取taskId
  239. const getTaskId=()=>{
  240. uni.getStorage({
  241. key:'saveTaskId',
  242. success: (res) => {
  243. console.log(res)
  244. createData.taskId = res.data.taskId
  245. }
  246. })
  247. }
  248. const getDpTaskDetail=()=>{
  249. http.get("app-api/taskDetail/get",{id:pageData.id}).then(res=>{
  250. console.log(res)
  251. pageData.dpList = res.results
  252. pageData.resData.results=res.results
  253. pageData.totalProgress=res.results.length
  254. data.reciper=res.detail.reciper
  255. if(res.detail.imageIds!=null){
  256. pageData.imageList = uploadImageModelValue(res.detail.imageIds)
  257. }
  258. })
  259. }
  260. onShow(()=>{
  261. if(pageData.operatorStatus=='add'){
  262. pageData.imageStatus=false
  263. pageData.disabledStatus=false
  264. createTask()
  265. }else{
  266. pageData.imageStatus=true
  267. pageData.disabledStatus=true
  268. getDpTaskDetail()
  269. }
  270. })
  271. onLoad((type)=>{
  272. console.log(type)
  273. if(type.state!=null){
  274. pageData.operatorStatus=type.state
  275. }
  276. if(type.cfbh!=null){
  277. pageData.cfbh=type.cfbh
  278. }
  279. if(type.ptwybh!=null){
  280. createData.pId=type.ptwybh
  281. pageData.cfbh=type.ptwybh
  282. }
  283. if(type.fyfslx!=null){
  284. createData.providerType=type.fyfslx
  285. }
  286. if(type.id!=null){
  287. pageData.id=type.id
  288. }
  289. })
  290. </script>
  291. <style lang="scss" scoped>
  292. @import 'index.scss';
  293. </style>