list.vue 9.2 KB

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