list.vue 9.8 KB

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