index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!-- 不良品列表 -->
  2. <template>
  3. <div class="ele-body">
  4. <el-card shadow="never" v-loading="loading">
  5. <order-search @search="reload" ref="searchRef"> </order-search>
  6. <ele-pro-table ref="table" :columns="columns" :datasource="datasource">
  7. <!-- 操作列 -->
  8. <template v-slot:toolbar>
  9. <el-button type="primary" @click="open()">新建</el-button>
  10. </template>
  11. <template v-slot:unqualifiedProductsCode="{ row }">
  12. <el-link
  13. type="primary"
  14. :underline="false"
  15. @click="goDetail(row, 'detail')"
  16. >{{ row.unqualifiedProductsCode }}</el-link
  17. >
  18. </template>
  19. <template v-slot:qualityType="{ row }">
  20. {{ getDictValue('质检计划类型', row.qualityType) }}
  21. </template>
  22. <template v-slot:createTime="{ row }">
  23. <span :class="isRed(row.createTime)">{{ row.createTime }}</span>
  24. </template>
  25. <template v-slot:action="{ row }">
  26. <el-link
  27. v-if="row.status == 0"
  28. type="primary"
  29. :underline="false"
  30. icon="el-icon-truck"
  31. @click="open(row)"
  32. >
  33. 编辑
  34. </el-link>
  35. <el-popconfirm
  36. class="ele-action"
  37. title="确定要删除吗?"
  38. v-if="row.status == 0"
  39. @confirm="remove(row)"
  40. >
  41. <template v-slot:reference>
  42. <el-link type="danger" :underline="false" icon="el-icon-delete">
  43. 删除
  44. </el-link>
  45. </template>
  46. </el-popconfirm>
  47. <el-link
  48. v-if="row.status == 0 || row.status == 1"
  49. type="primary"
  50. :underline="false"
  51. icon="el-icon-edit"
  52. @click="goDetail(row)"
  53. >
  54. 处置
  55. </el-link>
  56. </template>
  57. </ele-pro-table>
  58. </el-card>
  59. <Create ref="create" @refresh="reload" />
  60. </div>
  61. </template>
  62. <script>
  63. import OrderSearch from './components/order-search.vue';
  64. import dictMixins from '@/mixins/dictMixins';
  65. import { unacceptedProductStatus } from '@/utils/util';
  66. import Create from './components/create';
  67. import { getList } from '@/api/unacceptedProduct/index';
  68. export default {
  69. components: {
  70. OrderSearch,
  71. Create
  72. },
  73. mixins: [dictMixins],
  74. data() {
  75. return {
  76. visible: false,
  77. loading: false,
  78. releasParams: {
  79. teamId: '',
  80. id: ''
  81. },
  82. current: null
  83. };
  84. },
  85. computed: {
  86. // 表格列配置
  87. columns() {
  88. return [
  89. {
  90. columnKey: 'index',
  91. label: '序号',
  92. type: 'index',
  93. width: 55,
  94. align: 'center',
  95. showOverflowTooltip: true,
  96. fixed: 'left'
  97. },
  98. {
  99. prop: 'unqualifiedProductsCode',
  100. label: '编码',
  101. slot: 'unqualifiedProductsCode',
  102. align: 'center',
  103. width: 150,
  104. showOverflowTooltip: true
  105. },
  106. {
  107. prop: 'sourceCode',
  108. label: '来源编码',
  109. align: 'center',
  110. width: 150,
  111. showOverflowTooltip: true
  112. },
  113. {
  114. prop: 'categoryCode',
  115. label: '物品编码',
  116. align: 'center',
  117. width: 160,
  118. showOverflowTooltip: true
  119. },
  120. {
  121. prop: 'categoryName',
  122. label: '物品名称',
  123. align: 'center',
  124. showOverflowTooltip: true
  125. },
  126. {
  127. prop: 'specification',
  128. label: '规格',
  129. align: 'center',
  130. width: 100,
  131. showOverflowTooltip: true
  132. },
  133. {
  134. prop: 'brandNum',
  135. label: '牌号',
  136. align: 'center',
  137. width: 100,
  138. showOverflowTooltip: true
  139. },
  140. {
  141. prop: 'modelType',
  142. label: '型号',
  143. align: 'center',
  144. width: 160,
  145. showOverflowTooltip: true
  146. },
  147. {
  148. prop: 'quantity',
  149. label: '数量',
  150. align: 'center',
  151. width: 80,
  152. showOverflowTooltip: true
  153. },
  154. // {
  155. // prop: 'unit',
  156. // label: '计量单位',
  157. // align: 'center',
  158. // width: 100,
  159. // showOverflowTooltip: true
  160. // },
  161. {
  162. prop: 'batchNo',
  163. label: '批次号',
  164. align: 'center',
  165. width: 100,
  166. showOverflowTooltip: true
  167. },
  168. // {
  169. // prop: 'produceRoutingName',
  170. // label: '工艺路线',
  171. // align: 'center',
  172. // width: 120,
  173. // showOverflowTooltip: true
  174. // },
  175. // {
  176. // prop: 'taskName',
  177. // label: '工序',
  178. // align: 'center',
  179. // width: 120,
  180. // showOverflowTooltip: true
  181. // },
  182. {
  183. prop: 'disposeTime',
  184. label: '处置时间',
  185. align: 'center',
  186. width: 180,
  187. showOverflowTooltip: true
  188. },
  189. {
  190. prop: 'qualityType',
  191. slot: 'qualityType',
  192. label: '质检类型',
  193. align: 'center',
  194. width: 120,
  195. showOverflowTooltip: true
  196. },
  197. {
  198. prop: 'createTime',
  199. slot: 'createTime',
  200. label: '创建时间',
  201. align: 'center',
  202. width: 160,
  203. showOverflowTooltip: true
  204. },
  205. {
  206. prop: 'status',
  207. label: '状态',
  208. align: 'center',
  209. width: 80,
  210. formatter: (row, column, cellValue) => {
  211. return this.getDictName('处置状态', cellValue);
  212. }
  213. },
  214. {
  215. columnKey: 'action',
  216. label: '操作',
  217. width: 200,
  218. align: 'center',
  219. resizable: false,
  220. fixed: 'right',
  221. slot: 'action'
  222. }
  223. ];
  224. },
  225. isRed() {
  226. return (givenTimeStr) => {
  227. // 解析给定的时间字符串
  228. const givenTime = new Date(givenTimeStr);
  229. // 检查时间是否有效
  230. if (isNaN(givenTime.getTime())) {
  231. throw new Error(
  232. '无效的时间格式,请使用类似 "2025-08-12 17:03:27" 的格式'
  233. );
  234. }
  235. // 获取当前时间
  236. const now = new Date();
  237. // 检查给定时间是否超过当前时间(超过当前时间的不算)
  238. if (givenTime > now) {
  239. return '';
  240. }
  241. // 计算时间差(毫秒)
  242. const timeDiff = now - givenTime;
  243. // 转换为天数(1天 = 24小时 * 60分钟 * 60秒 * 1000毫秒)
  244. const daysDiff = timeDiff / (1000 * 60 * 60 * 24);
  245. // 判断是否大于5天
  246. return daysDiff > 5 ? 'is_red' : '';
  247. };
  248. }
  249. },
  250. created() {
  251. this.requestDict('质检计划类型');
  252. this.requestDict('处置状态');
  253. },
  254. filters: {},
  255. methods: {
  256. //处置
  257. goDetail(row, type) {
  258. this.$router.push({
  259. path: '/unqualifiedProduct/unqualifiedList/detailList',
  260. query: {
  261. id: row.id,
  262. qualityType: row.qualityType,
  263. type
  264. }
  265. });
  266. },
  267. /* 表格数据源 */
  268. datasource({ page, limit, where }) {
  269. return getList({
  270. pageNum: page,
  271. size: limit,
  272. ...where
  273. });
  274. },
  275. open(row) {
  276. this.$refs.create.open(row ? JSON.parse(JSON.stringify(row)) : '');
  277. },
  278. remove(row) {
  279. deleteUnacceptedProduct(row.id).then((res) => {
  280. this.$message.success('删除' + res);
  281. this.reload();
  282. });
  283. },
  284. // // 下达
  285. // toRelease(row) {
  286. // this.current = row;
  287. // this.visible = true;
  288. // },
  289. // // 下达
  290. // confirm(row) {
  291. // this.$confirm('确认下发选中的任务吗?', '提示', {
  292. // confirmButtonText: '确定',
  293. // cancleButtonText: '取消',
  294. // type: 'warning'
  295. // })
  296. // .then(async () => {
  297. // const res = await issuedPutMeshWorkOrder({
  298. // id: [row.id],
  299. // status: 1
  300. // });
  301. // this.$message.success('任务下发成功!');
  302. // this.reload();
  303. // })
  304. // .catch(() => {});
  305. // },
  306. /* 刷新表格 */
  307. reload(where) {
  308. this.$nextTick(() => {
  309. this.$refs.table.reload({ page: 1, where });
  310. });
  311. }
  312. }
  313. };
  314. </script>
  315. <style lang="scss" scoped>
  316. .is_red {
  317. color: red;
  318. }
  319. </style>