list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar v-if="way != 'todo' && way != 'done'" fixed="true" statusBar="true" left-icon="back"
  4. :title="pageName=='myList'?'我的质检工单':pageName=='myInspectionProjectTask'?'我的质检任务单':pageName=='myInspectionProjectEntrusted'?'我的质检受托单':'质检工单'"
  5. @clickLeft="back">
  6. </uni-nav-bar>
  7. <view class="top-wrapper">
  8. <uni-section>
  9. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="keyWord" placeholder="名称、批次号、工单编码">
  10. </uni-easyinput>
  11. </uni-section>
  12. <button class="search_btn" @click="doSearch">搜索</button>
  13. </view>
  14. <div style="height:100rpx;width: 475rpx;"></div>
  15. <view class="wrapper">
  16. <u-list @scrolltolower="scrolltolower" class="listContent">
  17. <view v-for="(item, index) in tableList" :key="index+item.id" style="position: relative;">
  18. <view class="item">
  19. <view class="herder_item">
  20. <view class="herder_text"></view>
  21. <view class="herder_view">
  22. {{ getDictValue('质检计划类型', item.qualityType+'')}}/{{item.code}}/{{item.productCode}}/{{item.productName}}
  23. <text v-if="!pageName||pageName=='myList'">
  24. ({{item.isPendingSample == 1?'待收样':statusList.find(row=>row.value==item.status).label}})
  25. </text>
  26. <text v-else>
  27. ({{statusList1.find(row=>row.value==item.status).label}})
  28. </text>
  29. <text>
  30. ({{item.recordingMethod==1?'按质检项检':"按样品检"}})
  31. </text>
  32. <text v-if="item.productLineName">
  33. {{item.productLineName}}
  34. </text>
  35. </view>
  36. </view>
  37. <view class="text">检验项目:</view>
  38. <view class="item_value" v-if="item.recordingMethod==1">
  39. <view @click="goTo(item.id,row.id,item.sampleMeasureUnit,item,row)"
  40. v-for="(row,_index) in item.templateList" :key="item.inspectionName+index+'_'+_index"
  41. :style="{background:row.status==1?'#19be6b':row.status==2?'#ff9900':row.status==3?'#ff9900':'#909399'}">
  42. {{row.inspectionName}}
  43. </view>
  44. </view>
  45. <view class="item_value" v-else>
  46. <view @click="goTo(item.id,row.id,item.sampleMeasureUnit,item,row)"
  47. v-for="(row,_index) in item.qualitySampleList" :key="item.sampleCode+index+'_'+_index"
  48. :style="{background:row.status==1?'#19be6b':row.status==2?'#ff9900':row.status==3?'#ff9900':'#909399'}">
  49. {{row.sampleCode}}
  50. </view>
  51. </view>
  52. <view class="text btnlist" v-if="![1, 2].includes(item.status)">
  53. 操作:
  54. <view style="display: flex;">
  55. <u-button v-if="item.isPendingSample == 1&&(pageName=='myList'||!pageName)" type="primary" text="收样"
  56. @click="sampleCollection(item)"></u-button>
  57. <u-button style="margin-left: 5px;" v-if="item.sampleQuantity < item.total &&item.isPendingSample != 1&&(pageName=='myList'||!pageName)"
  58. type="primary" text="请样" @click="addSampleOpen(item)"></u-button>
  59. <u-button style="margin-left: 5px;" v-if="item.recordingMethod != 1" type="primary" text="批量质检"
  60. @click="goTo(item.id,'',item.sampleMeasureUnit,item,{})">
  61. </u-button>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view style="width:100%;height:40rpx"></view>
  67. <view style='margin-top: 20vh;' v-if="tableList.length==0">
  68. <u-empty iconSize='150' textSize='32' text='暂无数据'>
  69. </u-empty>
  70. </view>
  71. </u-list>
  72. </view>
  73. <u-toast ref="uToast"></u-toast>
  74. <addSample ref='addSampleRef' @reload="doSearch"></addSample>
  75. </view>
  76. </template>
  77. <script>
  78. import dictMixns from '@/mixins/dictMixins'
  79. import addSample from './addSample.vue'
  80. import {
  81. getList,
  82. getRequestentrustList,
  83. sampleCollection,
  84. getTaskmonadList,
  85. verificationQualityInspector,
  86. checkByQualityWorkOrderId
  87. } from '@/api/inspectionWork/index.js'
  88. export default {
  89. components: {
  90. addSample
  91. },
  92. mixins: [dictMixns],
  93. props: {
  94. pageName: {
  95. default: ""
  96. },
  97. way: {
  98. default: 'route'
  99. },
  100. produceFilter: {
  101. type: Object,
  102. default: () => ({})
  103. }
  104. },
  105. data() {
  106. return {
  107. statusList: [{
  108. value: 0,
  109. label: '未报工'
  110. },
  111. {
  112. value: 1,
  113. label: '已报工'
  114. },
  115. {
  116. value: 2,
  117. label: '已关闭'
  118. },
  119. {
  120. value: 3,
  121. label: '待请样'
  122. }
  123. ],
  124. statusList1: [{
  125. value: 1,
  126. label: '未报工'
  127. },
  128. {
  129. value: 2,
  130. label: '已报工'
  131. }
  132. ],
  133. tableList: [],
  134. page: 1,
  135. size: 10,
  136. isEnd: false,
  137. keyWord: '',
  138. userInfo: {}
  139. }
  140. },
  141. computed: {
  142. },
  143. created() {
  144. this.requestDict('质检计划类型')
  145. },
  146. onLoad() {
  147. },
  148. methods: {
  149. buildQueryData(baseData = {}) {
  150. const data = {
  151. ...baseData
  152. }
  153. if (this.produceFilter && this.produceFilter.produceSourceTaskId) {
  154. data.produceSourceTaskId = this.produceFilter.produceSourceTaskId
  155. }
  156. if (this.produceFilter && this.produceFilter.workOrderCode) {
  157. data.workOrderCodeList = [this.produceFilter.workOrderCode]
  158. }
  159. return data
  160. },
  161. successInit() {
  162. uni.showLoading({
  163. title: '加载中'
  164. })
  165. let data = this.buildQueryData({
  166. pageNum: 1,
  167. size: this.tableList.length,
  168. keyWord: this.keyWord,
  169. // recordingMethod: 1,
  170. })
  171. if (this.pageName) {
  172. data.currentLoginUserId = this.userInfo.userId
  173. }
  174. if (this.pageName == 'myInspectionProjectEntrusted') {
  175. data.approvalStatus = 2
  176. }
  177. if (this.way == 'todo') {
  178. data.status = 0
  179. }
  180. if (this.way == 'done') {
  181. data.status = 1
  182. }
  183. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadList : this.pageName ==
  184. 'myInspectionProjectEntrusted' ? getRequestentrustList : getList
  185. api(data).then(res => {
  186. this.tableList = res.list
  187. }).then(() => {
  188. uni.hideLoading()
  189. })
  190. },
  191. doSearch() {
  192. this.isEnd = false
  193. this.page = 1
  194. this.getList()
  195. },
  196. //获取列表信息
  197. getList() {
  198. this.userInfo = uni.getStorageSync('userInfo')
  199. if (this.isEnd || !this.userInfo.userId) {
  200. return
  201. }
  202. uni.showLoading({
  203. title: '加载中'
  204. })
  205. let data = this.buildQueryData({
  206. pageNum: this.page,
  207. size: this.size,
  208. keyWord: this.keyWord,
  209. // recordingMethod: 1,
  210. })
  211. if (this.pageName) {
  212. data.currentLoginUserId = this.userInfo.userId
  213. }
  214. if (this.pageName == 'myInspectionProjectEntrusted') {
  215. data.approvalStatus = 2
  216. }
  217. if (this.way == 'todo') {
  218. data.status = 0
  219. }
  220. if (this.way == 'done') {
  221. data.status = 1
  222. }
  223. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadList : this.pageName ==
  224. 'myInspectionProjectEntrusted' ? getRequestentrustList : getList
  225. api(data).then(res => {
  226. if (this.page === 1) {
  227. this.tableList = res.list
  228. } else {
  229. this.tableList.push(...res.list)
  230. }
  231. this.page += 1
  232. this.isEnd = this.tableList.length >= res.count
  233. }).then(() => {
  234. uni.hideLoading()
  235. })
  236. },
  237. async sampleCollection(row) {
  238. if (!this.pageName) {
  239. const code = await verificationQualityInspector(row.id);
  240. if (code == '-1') {
  241. return;
  242. }
  243. }
  244. sampleCollection({
  245. id: row.id
  246. }).then((res) => {
  247. this.$refs.uToast.show({
  248. type: "success",
  249. icon: false,
  250. message: "收样成功",
  251. }, )
  252. this.doSearch();
  253. });
  254. },
  255. goTo(workId, projectId, sampleMeasureUnit, item, row) {
  256. if (this.pageName == 'myList' || !this.pageName) {
  257. if (item.isPendingSample == 1 && row.status != 1) {
  258. this.$refs.uToast.show({
  259. type: "error",
  260. icon: false,
  261. message: "请先完成收样!",
  262. }, )
  263. return
  264. }
  265. if (item.status == 3) {
  266. this.$refs.uToast.show({
  267. type: "error",
  268. icon: false,
  269. message: "请先完成请样!",
  270. }, )
  271. return
  272. }
  273. }
  274. if (item.recordingMethod == 1) {
  275. uni.navigateTo({
  276. url: '/pages/qms/inspectionWork/inspectionProjectReport?workId=' + workId + '&projectId=' +
  277. projectId + '&pageName=' + this.pageName + '&sampleMeasureUnit=' + sampleMeasureUnit
  278. })
  279. } else {
  280. uni.navigateTo({
  281. url: '/pages/qms/inspectionWork/sampleList?workId=' + workId + '&projectId=' +
  282. projectId + '&pageName=' + this.pageName
  283. })
  284. }
  285. },
  286. async addSampleOpen(row) {
  287. const code = await verificationQualityInspector(row.id);
  288. if (code == '-1') {
  289. return;
  290. }
  291. const is = await checkByQualityWorkOrderId(row.id);
  292. if (is) {
  293. this.$refs.uToast.show({
  294. type: "error",
  295. icon: false,
  296. message: "此工单存在未处理完的请样记录,请检查!",
  297. }, )
  298. return;
  299. }
  300. this.$refs.addSampleRef.open('add', row);
  301. },
  302. scrolltolower() {
  303. if (this.isEnd) {
  304. return
  305. }
  306. this.getList();
  307. },
  308. }
  309. }
  310. </script>
  311. <style lang="scss" scoped>
  312. .mainBox {
  313. background-color: #f3f8fb
  314. }
  315. // .wrapper{
  316. // }
  317. .top-wrapper {
  318. background-color: #fff;
  319. display: flex;
  320. width: 750rpx;
  321. height: 88rpx;
  322. padding: 16rpx 32rpx;
  323. align-items: center;
  324. // gap: 16rpx;
  325. position: absolute;
  326. z-index: 999;
  327. // top: 44px;
  328. // // #ifdef APP-PLUS
  329. // top: 140rpx;
  330. // // #endif
  331. /deep/.uni-section {
  332. margin-top: 0px;
  333. }
  334. /deep/.uni-section-header {
  335. padding: 0px;
  336. }
  337. .search_btn {
  338. width: 120rpx;
  339. height: 70rpx;
  340. line-height: 70rpx;
  341. padding: 0 24rpx;
  342. background: $theme-color;
  343. font-size: 32rpx;
  344. color: #fff;
  345. margin: 0;
  346. margin-left: 26rpx;
  347. }
  348. .menu_icon {
  349. width: 44rpx;
  350. height: 44rpx;
  351. margin-left: 14rpx;
  352. }
  353. }
  354. .item {
  355. width: 720rpx;
  356. // height:400rpx;
  357. margin: 20rpx auto 0;
  358. padding: 26rpx;
  359. border-radius: 30rpx;
  360. .text {
  361. margin-top: 20rpx;
  362. }
  363. background: #fff;
  364. }
  365. .item_value {
  366. width: 100%;
  367. display: flex;
  368. flex-wrap: wrap;
  369. margin-left: -10rpx;
  370. >view {
  371. font-size: 24rpx;
  372. color: #fff;
  373. padding: 12rpx;
  374. border-radius: 10rpx;
  375. background: #979797;
  376. margin-left: 10rpx;
  377. margin-top: 20rpx;
  378. }
  379. }
  380. .herder_item {
  381. display: flex;
  382. // align-items: center;
  383. font-size: 28rpx;
  384. font-weight: bold;
  385. .herder_view {
  386. width: calc(100% - 20rpx);
  387. word-break: break-all;
  388. }
  389. .herder_text {
  390. min-width: 10rpx;
  391. height: 32rpx;
  392. border-radius: 10rpx;
  393. background: #00c0a1;
  394. margin-right: 12rpx;
  395. margin-top: 5rpx;
  396. }
  397. }
  398. .btnlist {
  399. display: flex;
  400. align-items: center;
  401. }
  402. /deep/.u-button {
  403. height: 60rpx;
  404. width: auto;
  405. }
  406. </style>