list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. },
  101. data() {
  102. return {
  103. statusList: [{
  104. value: 0,
  105. label: '未报工'
  106. },
  107. {
  108. value: 1,
  109. label: '已报工'
  110. },
  111. {
  112. value: 2,
  113. label: '已关闭'
  114. },
  115. {
  116. value: 3,
  117. label: '待请样'
  118. }
  119. ],
  120. statusList1: [{
  121. value: 1,
  122. label: '未报工'
  123. },
  124. {
  125. value: 2,
  126. label: '已报工'
  127. }
  128. ],
  129. tableList: [],
  130. page: 1,
  131. size: 10,
  132. isEnd: false,
  133. keyWord: '',
  134. userInfo: {}
  135. }
  136. },
  137. computed: {
  138. },
  139. created() {
  140. this.requestDict('质检计划类型')
  141. },
  142. onLoad() {
  143. },
  144. methods: {
  145. successInit() {
  146. uni.showLoading({
  147. title: '加载中'
  148. })
  149. let data = {
  150. pageNum: 1,
  151. size: this.tableList.length,
  152. keyWord: this.keyWord,
  153. // recordingMethod: 1,
  154. }
  155. if (this.pageName) {
  156. data.currentLoginUserId = this.userInfo.userId
  157. }
  158. if (this.pageName == 'myInspectionProjectEntrusted') {
  159. data.approvalStatus = 2
  160. }
  161. if (this.way == 'todo') {
  162. data.status = 0
  163. }
  164. if (this.way == 'done') {
  165. data.status = 1
  166. }
  167. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadList : this.pageName ==
  168. 'myInspectionProjectEntrusted' ? getRequestentrustList : getList
  169. api(data).then(res => {
  170. this.tableList = res.list
  171. }).then(() => {
  172. uni.hideLoading()
  173. })
  174. },
  175. doSearch() {
  176. this.isEnd = false
  177. this.page = 1
  178. this.getList()
  179. },
  180. //获取列表信息
  181. getList() {
  182. this.userInfo = uni.getStorageSync('userInfo')
  183. if (this.isEnd || !this.userInfo.userId) {
  184. return
  185. }
  186. uni.showLoading({
  187. title: '加载中'
  188. })
  189. let data = {
  190. pageNum: this.page,
  191. size: this.size,
  192. keyWord: this.keyWord,
  193. // recordingMethod: 1,
  194. }
  195. if (this.pageName) {
  196. data.currentLoginUserId = this.userInfo.userId
  197. }
  198. if (this.pageName == 'myInspectionProjectEntrusted') {
  199. data.approvalStatus = 2
  200. }
  201. if (this.way == 'todo') {
  202. data.status = 0
  203. }
  204. if (this.way == 'done') {
  205. data.status = 1
  206. }
  207. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadList : this.pageName ==
  208. 'myInspectionProjectEntrusted' ? getRequestentrustList : getList
  209. api(data).then(res => {
  210. if (this.page === 1) {
  211. this.tableList = res.list
  212. } else {
  213. this.tableList.push(...res.list)
  214. }
  215. this.page += 1
  216. this.isEnd = this.tableList.length >= res.count
  217. }).then(() => {
  218. uni.hideLoading()
  219. })
  220. },
  221. async sampleCollection(row) {
  222. if (!this.pageName) {
  223. const code = await verificationQualityInspector(row.id);
  224. if (code == '-1') {
  225. return;
  226. }
  227. }
  228. sampleCollection({
  229. id: row.id
  230. }).then((res) => {
  231. this.$refs.uToast.show({
  232. type: "success",
  233. icon: false,
  234. message: "收样成功",
  235. }, )
  236. this.doSearch();
  237. });
  238. },
  239. goTo(workId, projectId, sampleMeasureUnit, item, row) {
  240. if (this.pageName == 'myList' || !this.pageName) {
  241. if (item.isPendingSample == 1 && row.status != 1) {
  242. this.$refs.uToast.show({
  243. type: "error",
  244. icon: false,
  245. message: "请先完成收样!",
  246. }, )
  247. return
  248. }
  249. if (item.status == 3) {
  250. this.$refs.uToast.show({
  251. type: "error",
  252. icon: false,
  253. message: "请先完成请样!",
  254. }, )
  255. return
  256. }
  257. }
  258. if (item.recordingMethod == 1) {
  259. uni.navigateTo({
  260. url: '/pages/qms/inspectionWork/inspectionProjectReport?workId=' + workId + '&projectId=' +
  261. projectId + '&pageName=' + this.pageName + '&sampleMeasureUnit=' + sampleMeasureUnit
  262. })
  263. } else {
  264. uni.navigateTo({
  265. url: '/pages/qms/inspectionWork/sampleList?workId=' + workId + '&projectId=' +
  266. projectId + '&pageName=' + this.pageName
  267. })
  268. }
  269. },
  270. async addSampleOpen(row) {
  271. const code = await verificationQualityInspector(row.id);
  272. if (code == '-1') {
  273. return;
  274. }
  275. const is = await checkByQualityWorkOrderId(row.id);
  276. if (is) {
  277. this.$refs.uToast.show({
  278. type: "error",
  279. icon: false,
  280. message: "此工单存在未处理完的请样记录,请检查!",
  281. }, )
  282. return;
  283. }
  284. this.$refs.addSampleRef.open('add', row);
  285. },
  286. scrolltolower() {
  287. if (this.isEnd) {
  288. return
  289. }
  290. this.getList();
  291. },
  292. }
  293. }
  294. </script>
  295. <style lang="scss" scoped>
  296. .mainBox {
  297. background-color: #f3f8fb
  298. }
  299. // .wrapper{
  300. // }
  301. .top-wrapper {
  302. background-color: #fff;
  303. display: flex;
  304. width: 750rpx;
  305. height: 88rpx;
  306. padding: 16rpx 32rpx;
  307. align-items: center;
  308. // gap: 16rpx;
  309. position: absolute;
  310. z-index: 999;
  311. // top: 44px;
  312. // // #ifdef APP-PLUS
  313. // top: 140rpx;
  314. // // #endif
  315. /deep/.uni-section {
  316. margin-top: 0px;
  317. }
  318. /deep/.uni-section-header {
  319. padding: 0px;
  320. }
  321. .search_btn {
  322. width: 120rpx;
  323. height: 70rpx;
  324. line-height: 70rpx;
  325. padding: 0 24rpx;
  326. background: $theme-color;
  327. font-size: 32rpx;
  328. color: #fff;
  329. margin: 0;
  330. margin-left: 26rpx;
  331. }
  332. .menu_icon {
  333. width: 44rpx;
  334. height: 44rpx;
  335. margin-left: 14rpx;
  336. }
  337. }
  338. .item {
  339. width: 720rpx;
  340. // height:400rpx;
  341. margin: 20rpx auto 0;
  342. padding: 26rpx;
  343. border-radius: 30rpx;
  344. .text {
  345. margin-top: 20rpx;
  346. }
  347. background: #fff;
  348. }
  349. .item_value {
  350. width: 100%;
  351. display: flex;
  352. flex-wrap: wrap;
  353. margin-left: -10rpx;
  354. >view {
  355. font-size: 24rpx;
  356. color: #fff;
  357. padding: 12rpx;
  358. border-radius: 10rpx;
  359. background: #979797;
  360. margin-left: 10rpx;
  361. margin-top: 20rpx;
  362. }
  363. }
  364. .herder_item {
  365. display: flex;
  366. // align-items: center;
  367. font-size: 28rpx;
  368. font-weight: bold;
  369. .herder_view {
  370. width: calc(100% - 20rpx);
  371. word-break: break-all;
  372. }
  373. .herder_text {
  374. min-width: 10rpx;
  375. height: 32rpx;
  376. border-radius: 10rpx;
  377. background: #00c0a1;
  378. margin-right: 12rpx;
  379. margin-top: 5rpx;
  380. }
  381. }
  382. .btnlist {
  383. display: flex;
  384. align-items: center;
  385. }
  386. /deep/.u-button {
  387. height: 60rpx;
  388. width: auto;
  389. }
  390. </style>