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.

414 lines
16 KiB

​
5 months ago
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
​
​
​
​
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
4 months ago
​
​
​
5 months ago
​
5 months ago
5 months ago
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months 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="planStartDate" label="计划开始日期" header-align="center" align="center" width="120"/>
  17. <el-table-column prop="planEndDate" label="计划结束日期" header-align="center" align="center" width="120"/>
  18. <el-table-column prop="inspectAddress" label="验货地址" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  19. <el-table-column prop="orderRef1" label="PO号" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  20. <el-table-column prop="supplierNo" label="供应商编码" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  21. <el-table-column prop="supplierName" label="供应商名称" header-align="center" align="left" min-width="200" show-overflow-tooltip/>
  22. <el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  23. <el-table-column prop="item" label="Item" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  24. <el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  25. <el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  26. <el-table-column prop="qty" label="验货数量" header-align="center" align="right" width="120"/>
  27. <el-table-column prop="approveQty" label="检验通过数量" header-align="center" align="right" width="120"/>
  28. <el-table-column prop="status" label="状态" header-align="center" align="center" width="100">
  29. <template slot-scope="scope">
  30. {{ getStatusText(scope.row.statusDb) }}
  31. </template>
  32. </el-table-column>
  33. <el-table-column prop="needInspectDate" label="建议验货日期" header-align="center" align="center" width="120"/>
  34. <el-table-column prop="qcOperator" label="QC人员" header-align="center" align="center" width="100"/>
  35. <el-table-column prop="inspectCityShort" label="城市简称" header-align="center" align="left" width="120" show-overflow-tooltip/>
  36. <el-table-column prop="inspectContract" label="联系人" header-align="center" align="center" width="100"/>
  37. <el-table-column prop="scheduleRemark" label="验货排程备注" header-align="center" align="center" width="100"/>
  38. <el-table-column fixed="right" header-align="center" align="center" width="180" label="操作">
  39. <template slot-scope="scope">
  40. <a v-if="scope.row.statusDb === 'Scheduled'" class="customer-a" @click="startInspection(scope.row)">开始验货</a>
  41. <a v-if="scope.row.statusDb === 'Scheduled'" class="customer-a" @click="handleEditQty(scope.row)">修改数量</a>
  42. <a v-if="scope.row.statusDb === 'Inspecting'" class="customer-a" @click="goToIQCResult(scope.row)">跳转</a>
  43. <a v-if="scope.row.statusDb === 'Scheduled' || scope.row.statusDb === 'Inspecting'" class="customer-a" style="color: #f56c6c;" @click="deleteInspection(scope.row)">删除</a>
  44. <span v-if="scope.row.statusDb === 'ChangeApplying'" style="color: #f56c6c;">等待变更审核</span>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <!-- 分页插件 -->
  49. <el-pagination
  50. style="margin-top: 10px"
  51. @size-change="sizeChangeHandle"
  52. @current-change="currentChangeHandle"
  53. :current-page="pageIndex"
  54. :page-sizes="[20, 50, 100, 200, 500]"
  55. :page-size="pageSize"
  56. :total="totalPage"
  57. layout="total, sizes, prev, pager, next, jumper">
  58. </el-pagination>
  59. </div>
  60. </template>
  61. <script>
  62. import { getMyInspectionList, createIqc, startInspection, deleteMyInspectionDetail, updateMyInspectionQty } from '@/api/inspection/inspectionRequestHeader.js'
  63. import { actionIQCInspection, qcIQCInspectionSearch } from '@/api/qc/qc.js'
  64. export default {
  65. components: {
  66. },
  67. name: 'MyInspectionList',
  68. data () {
  69. return {
  70. height: 400,
  71. loading: false,
  72. dataList: [],
  73. pageIndex: 1,
  74. pageSize: 50,
  75. totalPage: 0,
  76. searchData: {
  77. site: this.$store.state.user.site,
  78. page: 1,
  79. limit: 50,
  80. statusDb: 'Scheduled,Inspecting,ChangeApplying'
  81. }
  82. }
  83. },
  84. mounted () {
  85. this.$nextTick(() => {
  86. this.height = window.innerHeight - 180
  87. })
  88. this.getList()
  89. },
  90. beforeDestroy () {
  91. },
  92. methods: {
  93. handleRefresh () {
  94. this.getList()
  95. },
  96. // 获取列表数据
  97. getList () {
  98. this.loading = true
  99. this.searchData.page = this.pageIndex
  100. this.searchData.limit = this.pageSize
  101. getMyInspectionList(this.searchData).then(({ data }) => {
  102. if (data.code === 0) {
  103. this.dataList = data.page.list || []
  104. this.pageIndex = data.page.currPage
  105. this.pageSize = data.page.pageSize
  106. this.totalPage = data.page.totalCount
  107. } else {
  108. this.$message.error((data && data.msg) || '获取列表失败')
  109. }
  110. this.loading = false
  111. this.$nextTick(() => {
  112. if (this.$refs.mainTable) {
  113. this.$refs.mainTable.doLayout()
  114. }
  115. })
  116. }).catch(() => {
  117. this.loading = false
  118. })
  119. },
  120. // 每页条数变化
  121. sizeChangeHandle (val) {
  122. this.pageSize = val
  123. this.pageIndex = 1
  124. this.getList()
  125. },
  126. // 当前页变化
  127. currentChangeHandle (val) {
  128. this.pageIndex = val
  129. this.getList()
  130. },
  131. // 状态转换
  132. getStatusText (statusDb) {
  133. const statusMap = {
  134. 'Draft': '草稿',
  135. 'Confirmed': '已确认',
  136. 'Scheduled': '已排程',
  137. 'Audited': '已审核',
  138. 'ChangeApplying': '申请变更中',
  139. 'Inspecting': '验货中',
  140. 'Completed': '已完成',
  141. 'Cancelled': '已取消'
  142. }
  143. return statusMap[statusDb] || statusDb || '-'
  144. },
  145. // 跳转到 IQCResultEntry 页面
  146. goToIQCResult (row) {
  147. // 使用检验单号进行跳转
  148. const inspectionNo = row.inspectNo || ''
  149. if (!inspectionNo) {
  150. this.$message.warning('未找到检验单号')
  151. return
  152. }
  153. this.$router.push({
  154. name: 'qc-IQCResultEntry',
  155. query: {
  156. inspectionNo: inspectionNo
  157. }
  158. })
  159. },
  160. // 删除验货申请明细
  161. deleteInspection (row) {
  162. this.$confirm(`确认删除该验货申请?\n申请单号:${row.requestNo}\n供应商:${row.supplierName}`, '提示', {
  163. confirmButtonText: '确定',
  164. cancelButtonText: '取消',
  165. type: 'warning'
  166. }).then(() => {
  167. deleteMyInspectionDetail({
  168. requestNo: row.requestNo,
  169. itemNo: row.itemNo
  170. }).then(({ data }) => {
  171. if (data.code === 0) {
  172. this.$message.success('删除成功')
  173. this.getList()
  174. } else {
  175. this.$message.error((data && data.msg) || '删除失败')
  176. }
  177. }).catch((error) => {
  178. this.$message.error('删除失败:' + error.message)
  179. })
  180. }).catch(() => {
  181. // 用户取消操作
  182. })
  183. },
  184. // 修改验货数量(仅未创建IQC检验单前)
  185. handleEditQty (row) {
  186. if (row.statusDb !== 'Scheduled') {
  187. this.$message.warning('只有已排程且未开始验货的申请可以修改验货数量,请刷新列表后重试')
  188. this.getList()
  189. return
  190. }
  191. this.$prompt('请输入新的验货数量', '修改验货数量', {
  192. confirmButtonText: '确定',
  193. cancelButtonText: '取消',
  194. inputValue: row.qty == null ? '' : String(row.qty),
  195. inputPattern: /^\d+(\.\d+)?$/,
  196. inputErrorMessage: '请输入有效的正数',
  197. inputValidator: (val) => {
  198. if (val === '' || val === null) return '验货数量不能为空'
  199. if (Number(val) <= 0) return '验货数量必须大于0'
  200. return true
  201. }
  202. }).then(({ value }) => {
  203. updateMyInspectionQty({
  204. requestNo: row.requestNo,
  205. itemNo: row.itemNo,
  206. qty: Number(value)
  207. }).then(({ data }) => {
  208. if (data.code === 0) {
  209. this.$message.success('修改验货数量成功')
  210. this.getList()
  211. } else {
  212. this.$message.error((data && data.msg) || '修改验货数量失败')
  213. }
  214. }).catch((error) => {
  215. this.$message.error('修改验货数量失败:' + error.message)
  216. })
  217. }).catch(() => {
  218. // 用户取消操作
  219. })
  220. },
  221. // 开始验货
  222. startInspection (row) {
  223. // 校验单子状态是否为已排程(防止页面数据滞后)
  224. if (row.statusDb !== 'Scheduled') {
  225. this.$message.warning('只有已排程状态的验货申请可以开始验货,请刷新列表后重试')
  226. this.getList()
  227. return
  228. }
  229. const publicOrderTip = row.qcOperator === '*' ? '\n该单为公共单(QC人员:*),开始验货后QC人员将改为您本人' : ''
  230. this.$confirm(`确认开始验货?\n申请单号:${row.requestNo}\n供应商:${row.supplierName}${publicOrderTip}`, '提示', {
  231. confirmButtonText: '确定',
  232. cancelButtonText: '取消',
  233. type: 'warning'
  234. }).then(() => {
  235. // 构建创建IQC的参数
  236. const iqcData = {
  237. site: row.site,
  238. requestNo: row.requestNo,
  239. itemNo: row.itemNo,
  240. scheduleRemark: row.scheduleRemark
  241. }
  242. // 第一步:调用 createIqc 接口
  243. createIqc(iqcData).then(({ data }) => {
  244. if (data.code === 0) {
  245. const inspectionNo = data.inspectionNo
  246. this.$message.success('IQC检验单创建成功:' + inspectionNo)
  247. // 第二步:createIqc 成功后,立即查询检验单并执行开始检验逻辑
  248. const searchParams = {
  249. site: row.site,
  250. userName: this.$store.state.user.name,
  251. inspectionNo: inspectionNo,
  252. inspectionTypeNo: '105',
  253. states: ['未开始', '待检验'],
  254. page: 1,
  255. limit: 1
  256. }
  257. qcIQCInspectionSearch(searchParams).then(({ data }) => {
  258. if (data.code === 0 && data.page.list && data.page.list.length > 0) {
  259. const iqcRecord = data.page.list[0]
  260. // 调用开始检验接口,更新状态为"待检验"
  261. const actionIQCData = {
  262. site: iqcRecord.site,
  263. buNo: iqcRecord.buNo,
  264. inspectionNo: inspectionNo,
  265. actionBy: this.$store.state.user.name,
  266. state: '待检验',
  267. equipmentList: []
  268. }
  269. actionIQCInspection(actionIQCData).then(({ data }) => {
  270. if (data.code === 0) {
  271. this.$message.success('开始检验成功')
  272. } else {
  273. this.$message.warning((data && data.msg) || '开始检验失败,但不影响后续操作')
  274. }
  275. // 第三步:执行原有的 startInspection 逻辑
  276. const startInspectionData = {
  277. requestNo: row.requestNo,
  278. itemNo: row.itemNo
  279. }
  280. startInspection(startInspectionData).then(({ data }) => {
  281. if (data.code === 0) {
  282. this.$message.success('开始验货成功')
  283. this.getList()
  284. this.$router.push({
  285. name: 'qc-IQCResultEntry',
  286. query: {
  287. inspectionNo: inspectionNo
  288. }
  289. })
  290. } else {
  291. this.$message.error((data && data.msg) || '开始验货失败')
  292. }
  293. }).catch((error) => {
  294. this.$message.error('开始验货失败:' + error.message)
  295. })
  296. }).catch((error) => {
  297. this.$message.warning('开始检验异常:' + error.message + ',继续执行后续操作')
  298. // 即使开始检验失败,也继续执行 startInspection
  299. const startInspectionData = {
  300. requestNo: row.requestNo,
  301. itemNo: row.itemNo
  302. }
  303. startInspection(startInspectionData).then(({ data }) => {
  304. if (data.code === 0) {
  305. this.$message.success('开始验货成功')
  306. this.getList()
  307. this.$router.push({
  308. name: 'qc-IQCResultEntry',
  309. query: {
  310. inspectionNo: inspectionNo
  311. }
  312. })
  313. } else {
  314. this.$message.error((data && data.msg) || '开始验货失败')
  315. }
  316. }).catch((error) => {
  317. this.$message.error('开始验货失败:' + error.message)
  318. })
  319. })
  320. } else {
  321. this.$message.warning('未找到检验单信息,将直接执行开始验货')
  322. // 如果查询不到检验单,直接执行原有的 startInspection 逻辑
  323. const startInspectionData = {
  324. requestNo: row.requestNo,
  325. itemNo: row.itemNo
  326. }
  327. startInspection(startInspectionData).then(({ data }) => {
  328. if (data.code === 0) {
  329. this.$message.success('开始验货成功')
  330. this.getList()
  331. this.$router.push({
  332. name: 'qc-IQCResultEntry',
  333. query: {
  334. inspectionNo: inspectionNo
  335. }
  336. })
  337. } else {
  338. this.$message.error((data && data.msg) || '开始验货失败')
  339. }
  340. }).catch((error) => {
  341. this.$message.error('开始验货失败:' + error.message)
  342. })
  343. }
  344. }).catch((error) => {
  345. this.$message.warning('查询检验单失败:' + error.message + ',将直接执行开始验货')
  346. // 查询失败,直接执行原有的 startInspection 逻辑
  347. const startInspectionData = {
  348. requestNo: row.requestNo,
  349. itemNo: row.itemNo
  350. }
  351. startInspection(startInspectionData).then(({ data }) => {
  352. if (data.code === 0) {
  353. this.$message.success('开始验货成功')
  354. this.getList()
  355. this.$router.push({
  356. name: 'qc-IQCResultEntry',
  357. query: {
  358. inspectionNo: inspectionNo
  359. }
  360. })
  361. } else {
  362. this.$message.error((data && data.msg) || '开始验货失败')
  363. }
  364. }).catch((error) => {
  365. this.$message.error('开始验货失败:' + error.message)
  366. })
  367. })
  368. } else {
  369. this.$message.error((data && data.msg) || '创建IQC检验单失败')
  370. }
  371. }).catch((error) => {
  372. this.$message.error('创建IQC检验单失败:' + error.message)
  373. })
  374. }).catch(() => {
  375. // 用户取消操作
  376. })
  377. }
  378. }
  379. }
  380. </script>
  381. <style scoped lang="scss">
  382. .customer-css {
  383. padding: 5px;
  384. }
  385. .toolbar {
  386. margin-bottom: 8px;
  387. }
  388. </style>