dpTask.vue 10 KB

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