list.vue 8.6 KB

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