You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
12 KiB

1 week ago
1 week ago
1 week ago
2 days ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
2 days ago
2 days ago
2 days ago
2 days ago
2 days ago
1 week ago
  1. <template>
  2. <div class="customer-css">
  3. <div class="toolbar">
  4. <el-button type="primary" icon="el-icon-refresh" @click="handleRefresh">刷新</el-button>
  5. </div>
  6. <!-- 列表 -->
  7. <el-table
  8. ref="mainTable"
  9. :data="dataList"
  10. :height="height"
  11. border
  12. highlight-current-row
  13. v-loading="loading"
  14. style="width: 100%">
  15. <el-table-column prop="requestNo" label="申请单号" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  16. <el-table-column prop="orderRef1" label="PO号" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  17. <el-table-column prop="supplierNo" label="供应商编码" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  18. <el-table-column prop="supplierName" label="供应商名称" header-align="center" align="left" min-width="200" show-overflow-tooltip/>
  19. <el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  20. <el-table-column prop="partDesc" label="产品名称" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  21. <el-table-column prop="qty" label="验货数量" header-align="center" align="right" width="120"/>
  22. <el-table-column prop="approveQty" label="检验通过数量" header-align="center" align="right" width="120"/>
  23. <el-table-column prop="status" label="状态" header-align="center" align="center" width="100">
  24. <template slot-scope="scope">
  25. {{ getStatusText(scope.row.statusDb) }}
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="needInspectDate" label="建议验货日期" header-align="center" align="center" width="120"/>
  29. <el-table-column prop="planStartDate" label="计划开始日期" header-align="center" align="center" width="120"/>
  30. <el-table-column prop="planEndDate" label="计划结束日期" header-align="center" align="center" width="120"/>
  31. <el-table-column prop="qcOperator" label="QC人员" header-align="center" align="center" width="100"/>
  32. <el-table-column prop="inspectAddress" label="验货地址" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  33. <el-table-column prop="inspectContract" label="联系人" header-align="center" align="center" width="100"/>
  34. <el-table-column fixed="right" header-align="center" align="center" width="120" label="操作">
  35. <template slot-scope="scope">
  36. <a v-if="scope.row.statusDb === 'Scheduled'" class="customer-a" @click="startInspection(scope.row)">开始验货</a>
  37. <a v-if="scope.row.statusDb === 'Inspecting'" class="customer-a" @click="goToIQCResult(scope.row)">跳转</a>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. <!-- 分页插件 -->
  42. <el-pagination
  43. style="margin-top: 10px"
  44. @size-change="sizeChangeHandle"
  45. @current-change="currentChangeHandle"
  46. :current-page="pageIndex"
  47. :page-sizes="[20, 50, 100, 200, 500]"
  48. :page-size="pageSize"
  49. :total="totalPage"
  50. layout="total, sizes, prev, pager, next, jumper">
  51. </el-pagination>
  52. </div>
  53. </template>
  54. <script>
  55. import { getMyInspectionList, createIqc, startInspection } from '@/api/inspection/inspectionRequestHeader.js'
  56. import { actionIQCInspection, qcIQCInspectionSearch } from '@/api/qc/qc.js'
  57. export default {
  58. components: {
  59. },
  60. name: 'MyInspectionList',
  61. data () {
  62. return {
  63. height: 400,
  64. loading: false,
  65. dataList: [],
  66. pageIndex: 1,
  67. pageSize: 50,
  68. totalPage: 0,
  69. searchData: {
  70. site: this.$store.state.user.site,
  71. page: 1,
  72. limit: 50,
  73. statusDb: 'Scheduled,Inspecting'
  74. }
  75. }
  76. },
  77. mounted () {
  78. this.$nextTick(() => {
  79. this.height = window.innerHeight - 180
  80. })
  81. this.getList()
  82. },
  83. beforeDestroy () {
  84. },
  85. methods: {
  86. handleRefresh () {
  87. this.getList()
  88. },
  89. // 获取列表数据
  90. getList () {
  91. this.loading = true
  92. this.searchData.page = this.pageIndex
  93. this.searchData.limit = this.pageSize
  94. getMyInspectionList(this.searchData).then(({ data }) => {
  95. if (data.code === 0) {
  96. this.dataList = data.page.list || []
  97. this.pageIndex = data.page.currPage
  98. this.pageSize = data.page.pageSize
  99. this.totalPage = data.page.totalCount
  100. } else {
  101. this.$message.error((data && data.msg) || '获取列表失败')
  102. }
  103. this.loading = false
  104. this.$nextTick(() => {
  105. if (this.$refs.mainTable) {
  106. this.$refs.mainTable.doLayout()
  107. }
  108. })
  109. }).catch(() => {
  110. this.loading = false
  111. })
  112. },
  113. // 每页条数变化
  114. sizeChangeHandle (val) {
  115. this.pageSize = val
  116. this.pageIndex = 1
  117. this.getList()
  118. },
  119. // 当前页变化
  120. currentChangeHandle (val) {
  121. this.pageIndex = val
  122. this.getList()
  123. },
  124. // 状态转换
  125. getStatusText (statusDb) {
  126. const statusMap = {
  127. 'Draft': '草稿',
  128. 'Confirmed': '已确认',
  129. 'Scheduled': '已排程',
  130. 'Audited': '已审核',
  131. 'Inspecting': '验货中',
  132. 'Completed': '已完成',
  133. 'Cancelled': '已取消'
  134. }
  135. return statusMap[statusDb] || statusDb || '-'
  136. },
  137. // 跳转到 IQCResultEntry 页面
  138. goToIQCResult (row) {
  139. // 使用检验单号进行跳转
  140. const inspectionNo = row.inspectNo || ''
  141. if (!inspectionNo) {
  142. this.$message.warning('未找到检验单号')
  143. return
  144. }
  145. this.$router.push({
  146. name: 'qc-IQCResultEntry',
  147. query: {
  148. inspectionNo: inspectionNo
  149. }
  150. })
  151. },
  152. // 开始验货
  153. startInspection (row) {
  154. this.$confirm(`确认开始验货?\n申请单号:${row.requestNo}\n供应商:${row.supplierName}`, '提示', {
  155. confirmButtonText: '确定',
  156. cancelButtonText: '取消',
  157. type: 'warning'
  158. }).then(() => {
  159. // 构建创建IQC的参数
  160. const iqcData = {
  161. site: row.site,
  162. requestNo: row.requestNo,
  163. itemNo: row.itemNo
  164. }
  165. // 第一步:调用 createIqc 接口
  166. createIqc(iqcData).then(({ data }) => {
  167. if (data.code === 0) {
  168. const inspectionNo = data.inspectionNo
  169. this.$message.success('IQC检验单创建成功:' + inspectionNo)
  170. // 第二步:createIqc 成功后,立即查询检验单并执行开始检验逻辑
  171. const searchParams = {
  172. site: row.site,
  173. userName: this.$store.state.user.name,
  174. inspectionNo: inspectionNo,
  175. inspectionTypeNo: '105',
  176. states: ['未开始', '待检验'],
  177. page: 1,
  178. limit: 1
  179. }
  180. qcIQCInspectionSearch(searchParams).then(({ data }) => {
  181. if (data.code === 0 && data.page.list && data.page.list.length > 0) {
  182. const iqcRecord = data.page.list[0]
  183. // 调用开始检验接口,更新状态为"待检验"
  184. const actionIQCData = {
  185. site: iqcRecord.site,
  186. buNo: iqcRecord.buNo,
  187. inspectionNo: inspectionNo,
  188. actionBy: this.$store.state.user.name,
  189. state: '待检验',
  190. equipmentList: []
  191. }
  192. actionIQCInspection(actionIQCData).then(({ data }) => {
  193. if (data.code === 0) {
  194. this.$message.success('开始检验成功')
  195. } else {
  196. this.$message.warning((data && data.msg) || '开始检验失败,但不影响后续操作')
  197. }
  198. // 第三步:执行原有的 startInspection 逻辑
  199. const startInspectionData = {
  200. requestNo: row.requestNo,
  201. itemNo: row.itemNo
  202. }
  203. startInspection(startInspectionData).then(({ data }) => {
  204. if (data.code === 0) {
  205. this.$message.success('开始验货成功')
  206. this.getList()
  207. this.$router.push({
  208. name: 'qc-IQCResultEntry',
  209. query: {
  210. inspectionNo: inspectionNo
  211. }
  212. })
  213. } else {
  214. this.$message.error((data && data.msg) || '开始验货失败')
  215. }
  216. }).catch((error) => {
  217. this.$message.error('开始验货失败:' + error.message)
  218. })
  219. }).catch((error) => {
  220. this.$message.warning('开始检验异常:' + error.message + ',继续执行后续操作')
  221. // 即使开始检验失败,也继续执行 startInspection
  222. const startInspectionData = {
  223. requestNo: row.requestNo,
  224. itemNo: row.itemNo
  225. }
  226. startInspection(startInspectionData).then(({ data }) => {
  227. if (data.code === 0) {
  228. this.$message.success('开始验货成功')
  229. this.getList()
  230. this.$router.push({
  231. name: 'qc-IQCResultEntry',
  232. query: {
  233. inspectionNo: inspectionNo
  234. }
  235. })
  236. } else {
  237. this.$message.error((data && data.msg) || '开始验货失败')
  238. }
  239. }).catch((error) => {
  240. this.$message.error('开始验货失败:' + error.message)
  241. })
  242. })
  243. } else {
  244. this.$message.warning('未找到检验单信息,将直接执行开始验货')
  245. // 如果查询不到检验单,直接执行原有的 startInspection 逻辑
  246. const startInspectionData = {
  247. requestNo: row.requestNo,
  248. itemNo: row.itemNo
  249. }
  250. startInspection(startInspectionData).then(({ data }) => {
  251. if (data.code === 0) {
  252. this.$message.success('开始验货成功')
  253. this.getList()
  254. this.$router.push({
  255. name: 'qc-IQCResultEntry',
  256. query: {
  257. inspectionNo: inspectionNo
  258. }
  259. })
  260. } else {
  261. this.$message.error((data && data.msg) || '开始验货失败')
  262. }
  263. }).catch((error) => {
  264. this.$message.error('开始验货失败:' + error.message)
  265. })
  266. }
  267. }).catch((error) => {
  268. this.$message.warning('查询检验单失败:' + error.message + ',将直接执行开始验货')
  269. // 查询失败,直接执行原有的 startInspection 逻辑
  270. const startInspectionData = {
  271. requestNo: row.requestNo,
  272. itemNo: row.itemNo
  273. }
  274. startInspection(startInspectionData).then(({ data }) => {
  275. if (data.code === 0) {
  276. this.$message.success('开始验货成功')
  277. this.getList()
  278. this.$router.push({
  279. name: 'qc-IQCResultEntry',
  280. query: {
  281. inspectionNo: inspectionNo
  282. }
  283. })
  284. } else {
  285. this.$message.error((data && data.msg) || '开始验货失败')
  286. }
  287. }).catch((error) => {
  288. this.$message.error('开始验货失败:' + error.message)
  289. })
  290. })
  291. } else {
  292. this.$message.error((data && data.msg) || '创建IQC检验单失败')
  293. }
  294. }).catch((error) => {
  295. this.$message.error('创建IQC检验单失败:' + error.message)
  296. })
  297. }).catch(() => {
  298. // 用户取消操作
  299. })
  300. }
  301. }
  302. }
  303. </script>
  304. <style scoped lang="scss">
  305. .customer-css {
  306. padding: 5px;
  307. }
  308. .toolbar {
  309. margin-bottom: 8px;
  310. }
  311. </style>