djhjTask.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="djhjTask">
  3. <!-- 任务进度 -->
  4. <view class="djhjTask_progress">
  5. <text class="djhjTask_progress_title">任务进度:<text class="djhjTask_progress_text">{{wwcNumber()}}/{{pageData.taskNum}}</text></text>
  6. <text class="djhjTask_progress_title">不合格数<text class="djhjTask_progress_text">{{bhgNumber()}}</text></text>
  7. </view>
  8. <!-- 操作人 -->
  9. <view class="operator" v-if="pageData.operatorName!=null && pageData.operatorName!=''">
  10. <text class="operator_title">操作人<text class="operator_text">{{pageData.operatorName}}</text></text>
  11. </view>
  12. <!-- 检查结果 -->
  13. <uni-card padding="0" spacing="0" v-for="(item,index) in pageData.resList.results" class="djhjList">
  14. <view class="djhjList_title">
  15. <view class="djhjList_text">检查项目</view>
  16. <view class="djhjList_righttext">{{item.item}}</view>
  17. </view>
  18. <view class="djhjList_title">
  19. <view class="djhjList_text">检查方式</view>
  20. <view class="djhjList_righttext">{{item.assessmentCriteria}}</view>
  21. </view>
  22. <view class="djhjList_title">
  23. <view class="djhjList_text">检查内容</view>
  24. <view class="djhjList_righttext">{{item.assessmentContent}}</view>
  25. </view>
  26. <view class="djhjList_title">
  27. <view class="djhjList_text">检查结果</view>
  28. <view :class="item.assessmentResult=='不合格'? 'djhjList_redtext' : item.assessmentResult=='待检' ? 'djhjList_bluetext':'djhjList_greentext'">{{item.assessmentResult}}</view>
  29. </view>
  30. <view class="djhjList_title" v-if="item.resultContent">
  31. <view class="djhjList_text">原因</view>
  32. <view class="djhjList_righttext">{{item.resultContent}}</view>
  33. </view>
  34. <view class="button_group">
  35. <view class="bhg_button" @click="bhgCheck(item)">不合格</view>
  36. <view class="hg_button" @click="hgCheck(item)">合格</view>
  37. </view>
  38. </uni-card>
  39. <!-- 图片上传 -->
  40. <view class="image_upload">
  41. <uni-card>
  42. <uni-section title="图片上传" type="line"></uni-section>
  43. <view class="img_upload">
  44. <uni-file-picker limit="4" :modelValue="showImage(pageData.imageList)" @select="selectImg" @delete="deleteImg"></uni-file-picker>
  45. </view>
  46. </uni-card>
  47. </view>
  48. <!-- 按钮组 -->
  49. <view class="operator_button">
  50. <!-- <button :class="pageData.buttonDisabled==false?'pass_button':'pass_button_grey'" @click="pass" :disabled="pageData.buttonDisabled">一键通过</button> -->
  51. <!-- 如果还有数据按钮显示为“下一个”,数据全部加载完毕显示为“完成” -->
  52. <!-- <view class="finish_button_grop"> -->
  53. <!-- <button class="next_or_finish_button" v-if="pageData.resList.results!=0" @click="next">下一个</button> -->
  54. <button class="next_or_finish_button_save" v-if="pageData.resList.results!=0" @click="save">保存</button>
  55. <button class="next_or_finish_button_allSave" v-if="pageData.taskNum != wwcNumber()" @click="openPassDialog">一键通过</button>
  56. <!-- <button class="next_or_finish_button_save" @click="finish" v-else>完成</button> -->
  57. <button class="next_or_finish_button" v-if="pageData.resList.results!=0" @click="next">提交</button>
  58. <!-- </view> -->
  59. </view>
  60. <!-- 不合格弹出框 -->
  61. <uni-popup ref="bhgDialog" type="dialog">
  62. <uni-popup-dialog type="info" mode="input" confirmText="提交" cancelText="取消" title="不合格原因" value="" placeholder="请填写不合格原因" @confirm="bhgDialogConfirm"
  63. @close="bhgDialogClose"></uni-popup-dialog>
  64. </uni-popup>
  65. <!-- 一键通过确认弹出框 -->
  66. <uni-popup ref="passDialog" type="dialog">
  67. <uni-popup-dialog type="info" confirmText="确定" cancelText="取消" :content="passMessage.showMessage" @confirm="operatorDialogConfirm" @close="operatorDialogClose"></uni-popup-dialog>
  68. </uni-popup>
  69. </view>
  70. </template>
  71. <script setup>
  72. import { ref,reactive, 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. import { UrlPath } from "@/utils/commonuni"
  77. const pageData=reactive({
  78. bhgNum:0,
  79. finishNum:'',
  80. taskNum:'',
  81. djhjList:[],
  82. imageList:[],
  83. resList:[],
  84. taskStatus:'',
  85. buttonDisabled:true,
  86. // 操作人姓名
  87. operatorName:''
  88. })
  89. const formData=reactive({
  90. id:''
  91. })
  92. const passMessage = reactive({
  93. showMessage:''
  94. })
  95. const passDialog = ref(null)
  96. // 临时创建代煎代配企业评估任务内容 入参
  97. const createData=reactive({
  98. taskId:'',
  99. pId:'',
  100. providerType:''
  101. })
  102. // 任务进度(已完成)
  103. const wwcNumber = () =>{
  104. let number = 0
  105. let data = pageData.resList.results
  106. if(data != null){
  107. for (var i = 0; i < data.length; i++) {
  108. if (data[i].assessmentResult != null && data[i].assessmentResult != undefined && data[i].assessmentResult != '待检')
  109. number ++;
  110. }
  111. }
  112. return number
  113. }
  114. // 不合格数
  115. const bhgNumber=()=>{
  116. let number=0
  117. if(pageData.resList.results!=null){
  118. pageData.resList.results.forEach(item=>{
  119. if(item.assessmentResult=='不合格'){
  120. number++
  121. }
  122. })
  123. }
  124. return number
  125. }
  126. // 定义不合格弹出输入框
  127. const bhgDialog=ref()
  128. // 提交不合格原因
  129. const bhgDialogConfirm=(val)=>{
  130. // 获取输入的不合格原因
  131. item.value.resultContent = val
  132. pageData.bhgNum=pageData.bhgNum+1
  133. pageData.resList.results.forEach((e,idx)=>{
  134. if(e.id==item.value.id){
  135. pageData.resList.results[idx]=item.value
  136. }
  137. })
  138. bhgDialog._value.close()
  139. item.value = {}
  140. }
  141. // 取消不合格弹出输入框
  142. const bhgDialogClose=()=>{
  143. // 关闭不合格弹出框
  144. item.value = {}
  145. bhgDialog._value.close()
  146. }
  147. // 选中图片,将选中的图片添加列表
  148. const selectImg=(e)=>{
  149. if(pageData.imageList==null || pageData.imageList == undefined){
  150. pageData.imageList=[]
  151. }
  152. e.tempFiles.forEach(item=>{
  153. uni.showLoading({
  154. title: '图片上传....',
  155. mask: true
  156. });
  157. http.upload("admin-api/infra/file/upload",{file:item.file}).then(e => {
  158. uni.hideLoading()
  159. pageData.imageList.push(e)
  160. })
  161. })
  162. console.log("上传后",pageData.imageList)
  163. }
  164. // 删除图片,并将其从列表中删除
  165. const deleteImg = (val) => {
  166. if (val.index != -1) {
  167. pageData.imageList.splice(val.index, 1);
  168. }
  169. };
  170. const item = ref({})
  171. // 不合格
  172. const bhgCheck=(e)=>{
  173. e.score=0
  174. if(e.assessmentResult=="合格" || e.assessmentResult=="待检"){
  175. e.assessmentResult="不合格"
  176. item.value = e
  177. // 打开不合格弹出输入框
  178. bhgDialog._value.open()
  179. }
  180. }
  181. // 合格
  182. const hgCheck=(e)=>{
  183. if(e.assessmentResult=='不合格' || e.assessmentResult=='待检'){
  184. e.assessmentResult='合格'
  185. e.score=e.totalScore
  186. e.resultContent=''
  187. }
  188. }
  189. // 一键通过
  190. const pass=()=>{
  191. pageData.finishNum=pageData.taskNum
  192. pageData.resList.results.forEach(item=>{
  193. if(item.isDj == null && (item.resultContent == null || item.resultContent == "")) {
  194. item.assessmentResult='合格'
  195. item.resultContent=''
  196. }
  197. })
  198. }
  199. // 打开一键通过弹窗
  200. const openPassDialog=()=>{
  201. passMessage.showMessage = "未填选项目是否一键通过?"
  202. passDialog.value.open()
  203. }
  204. // 弹窗确认事件
  205. const operatorDialogConfirm = () => {
  206. pass()
  207. operatorDialogClose()
  208. }
  209. // 关闭一键通过弹窗
  210. const operatorDialogClose=()=>{
  211. passDialog.value.close()
  212. }
  213. // 计算环境质控总分
  214. const countTotal=()=>{
  215. pageData.resList.resultContent=0
  216. pageData.resList.results.forEach(item=>{
  217. pageData.resList.resultContent+=Number(item.score)
  218. })
  219. }
  220. // 保存环境质控
  221. const saveHjTask=()=>{
  222. if(pageData.imageList!=null && pageData.imageList!=undefined && pageData.imageList.length!=0){
  223. pageData.resList.detail.imageIds=pageData.imageList.toString()
  224. console.log("内容",pageData.resList.detail)
  225. console.log("内容2",pageData.imageList)
  226. uni.showLoading({
  227. title: '提交中.......',
  228. mask: true
  229. });
  230. http.post("app-api/zkzy/save",pageData.resList).then(res=>{
  231. uni.hideLoading()
  232. if(res==true){
  233. uni.showToast({
  234. title: '提交成功',
  235. success: () => {
  236. uni.navigateBack({
  237. delta:1
  238. })
  239. }
  240. });
  241. }else{
  242. uni.showToast({
  243. title: '提交失败'
  244. });
  245. }
  246. })
  247. }else{
  248. uni.showToast({
  249. title: '请上传图片',
  250. icon: 'none'
  251. });
  252. }
  253. }
  254. // 保存
  255. const save=()=>{
  256. pageData.resList.detail.fyfsyf="xcpg"
  257. pageData.resList.detail.imageIds=pageData.imageList.toString()
  258. uni.showLoading({
  259. title: '保存中.......',
  260. mask: true
  261. });
  262. http.post("app-api/zkzy/save",pageData.resList).then(res=>{
  263. uni.hideLoading()
  264. if(res==true){
  265. uni.showToast({
  266. title: '保存成功',
  267. });
  268. }else{
  269. uni.showToast({
  270. title: '保存失败'
  271. });
  272. }
  273. })
  274. }
  275. // 下一个
  276. const next=()=>{
  277. pageData.resList.detail.fyfsyf="xcpg"
  278. if(wwcNumber()==pageData.taskNum){
  279. countTotal()
  280. saveHjTask()
  281. }else{
  282. uni.showToast({
  283. title: '提交失败,请检查任务进度',
  284. icon:'error'
  285. });
  286. }
  287. }
  288. // 完成
  289. const finish=()=>{
  290. pageData.resList.detail.fyfsyf="xcpg"
  291. saveHjTask()
  292. }
  293. // 获取taskId
  294. const getTaskId=()=>{
  295. uni.getStorage({
  296. key:'saveTaskId',
  297. success: (res) => {
  298. createData.taskId = res.data.taskId
  299. }
  300. })
  301. }
  302. // 临时创建代煎代配企业评估任务内容
  303. const createTask=()=>{
  304. createData.providerType="xcpg"
  305. getTaskId()
  306. http.get("app-api/zkzy/create",createData).then(res=>{
  307. getHJTask(res)
  308. })
  309. }
  310. // 获取环境质控质控作业
  311. const getHJTask=(data)=>{
  312. formData.id=data
  313. http.get("app-api/taskDetail/get",formData).then(res=>{
  314. pageData.resList=res
  315. pageData.finishNum=0
  316. pageData.bhgNum=0
  317. pageData.taskNum = pageData.resList.results.length
  318. pageData.operatorName=res.detail.creatorName
  319. if(pageData.resList.detail.status=="2" || pageData.resList.detail.status=="1"){
  320. pageData.resList.results.forEach(item=>{
  321. if(item.score==item.totalScore && !item.isDj){
  322. item.assessmentResult='合格'
  323. }else{
  324. item.assessmentResult = item.isDj ? '待检' : '不合格'
  325. }
  326. })
  327. }else{
  328. pageData.resList.results.forEach(item=>{
  329. // 一开始均为“待检状态”
  330. item.assessmentResult='待检'
  331. })
  332. }
  333. if(res.detail.imageIds!=null && res.detail.imageIds!=''){
  334. if(typeof(res.detail.imageIds)=='string'){
  335. var urls=res.detail.imageIds.split(',')
  336. pageData.imageList=[]
  337. urls.forEach(e=>{
  338. pageData.imageList.push(e)
  339. })
  340. }
  341. }
  342. })
  343. }
  344. // 显示图片
  345. const showImage = (urlStr) => {
  346. const rawPrefix = UrlPath.getBaseUrl()
  347. const prefix = rawPrefix.replace(/\/+$/, '');
  348. const result = urlStr.map(url => {
  349. return prefix + url;
  350. });
  351. return result;
  352. }
  353. onShow(()=>{
  354. setTimeout(()=>{
  355. pageData.buttonDisabled=false
  356. },5000)
  357. })
  358. onLoad(()=>{
  359. createTask()
  360. })
  361. </script>
  362. <style lang="scss" scoped>
  363. @import './index.scss'
  364. </style>