list.vue 8.9 KB

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