index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <ele-split-layout
  5. width="500px"
  6. allow-collapse
  7. :right-style="{ overflow: 'hidden' }"
  8. >
  9. <div class="left-box">
  10. <div class="left-item">
  11. <div class="title">产品</div>
  12. <el-popover placement="right" width="400" trigger="click">
  13. <div>
  14. <el-form
  15. ref="productFormRef"
  16. :model="productBody"
  17. label-width="80px"
  18. class="productForm"
  19. >
  20. <el-form-item label="关键字:">
  21. <el-input
  22. v-model="productBody.param"
  23. placeholder="产品编码、产品名称"
  24. ></el-input>
  25. </el-form-item>
  26. <el-form-item label="查询范围:">
  27. <el-date-picker
  28. style="width: 100%"
  29. v-model="productBody.createTimeStart"
  30. type="date"
  31. placeholder="选择日期"
  32. format="yyyy-MM-dd HH:mm:ss"
  33. value-format="yyyy-MM-dd HH:mm:ss"
  34. :picker-options="{
  35. disabledDate: (date) => {
  36. const end = productBody.createTimeEnd
  37. ? new Date(productBody.createTimeEnd)
  38. : new Date();
  39. const start = new Date(end);
  40. start.setMonth(start.getMonth() - 3);
  41. return (
  42. date.getTime() < start.getTime() ||
  43. date.getTime() > end.getTime()
  44. );
  45. }
  46. }"
  47. >
  48. </el-date-picker>
  49. <div style="margin-top: 10px">
  50. <el-date-picker
  51. style="width: 100%"
  52. v-model="productBody.createTimeEnd"
  53. type="date"
  54. placeholder="选择日期"
  55. format="yyyy-MM-dd HH:mm:ss"
  56. value-format="yyyy-MM-dd HH:mm:ss"
  57. @change="createTimeEndDateChange"
  58. :picker-options="{
  59. disabledDate: (date) => {
  60. const now = new Date();
  61. const start = new Date(now);
  62. start.setMonth(start.getMonth() - 3);
  63. return (
  64. date.getTime() < start.getTime() ||
  65. date.getTime() > now.getTime()
  66. );
  67. }
  68. }"
  69. >
  70. </el-date-picker>
  71. </div>
  72. </el-form-item>
  73. <el-form-item>
  74. <el-button
  75. type="primary"
  76. @click="getAllProductInWorkOrder"
  77. icon="el-icon-search"
  78. :loading="productButLoading"
  79. >查询</el-button
  80. >
  81. <el-button
  82. type="primary"
  83. @click="resetSubmit"
  84. icon="el-icon-refresh-left"
  85. :loading="productButLoading"
  86. >重置</el-button
  87. >
  88. </el-form-item>
  89. </el-form>
  90. </div>
  91. <el-button slot="reference" type="primary" style="width: 100%">
  92. 搜索
  93. </el-button>
  94. </el-popover>
  95. <div class="list-box" style="padding-bottom: 80px">
  96. <div
  97. class="list-item"
  98. v-for="i in productList"
  99. :key="i.productName + i.productCode"
  100. :class="{ active: i.productCode == tableQuery.productCode }"
  101. @click="changeProductName(i)"
  102. >
  103. <!-- <el-popover
  104. placement="top-start"
  105. width="200"
  106. trigger="hover"
  107. :content="`产品编码:${i.productCode},产品名称:${i.productName}`"
  108. >
  109. <template slot="reference">
  110. <div class="ele-elip" style="width: 100%">{{
  111. i.productCode
  112. }}</div>
  113. <div class="ele-elip" style="width: 100%">{{
  114. i.productName
  115. }}</div>
  116. </template>
  117. </el-popover> -->
  118. <div class="ele-elip" style="width: 100%">
  119. {{ i.productCode }}
  120. </div>
  121. <div class="ele-elip" style="width: 100%">
  122. {{ i.productName }}
  123. </div>
  124. </div>
  125. </div>
  126. <div class="footer-box">
  127. <el-pagination
  128. @size-change="handleSizeChange"
  129. @current-change="handleCurrentChange"
  130. :current-page.sync="productBody.pageNum"
  131. :page-size="productBody.size"
  132. layout="sizes,pager"
  133. :total="total"
  134. :pager-count="5"
  135. small
  136. >
  137. </el-pagination>
  138. </div>
  139. </div>
  140. <div class="left-item">
  141. <div class="title">批次号</div>
  142. <div v-if="batchNos.length > 0" class="list-box">
  143. <div
  144. class="list-item"
  145. v-for="i in batchNos"
  146. :key="i"
  147. :class="{ active: i == tableQuery.batchNo }"
  148. @click="changeBatchNo(i)"
  149. >
  150. <div> {{ i ? i : '暂无批次号' }}</div>
  151. </div>
  152. </div>
  153. <div v-else class="list-box">
  154. <div class="list-item" style="text-align: center; color: #888">
  155. 请先选择产品
  156. </div>
  157. </div>
  158. </div>
  159. <div class="left-item">
  160. <div class="title">批记录类型</div>
  161. <div class="list-box">
  162. <div
  163. class="list-item"
  164. v-for="i in types"
  165. :key="i.name"
  166. :class="{ active: activeType == i.name }"
  167. @click="changeActiveType(i)"
  168. >
  169. {{ i.name }}
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <template v-slot:content>
  175. <div class="table-box">
  176. <component
  177. :is="activeComponentName"
  178. ref="tableRef"
  179. :tableQuery="tableQuery"
  180. ></component>
  181. </div>
  182. </template>
  183. </ele-split-layout>
  184. </el-card>
  185. </div>
  186. </template>
  187. <script>
  188. import dictMixins from '@/mixins/dictMixins';
  189. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  190. import seekPage from '@/components/common/seekPage.vue';
  191. import { getAllProductInWorkOrder } from '@/api/produce/workOrder';
  192. import workOrderTable from './components/tables/workOrderTable.vue';
  193. import materialTable from './components/tables/materialTable.vue';
  194. import materialReturnTable from './components/tables/materialReturnTable.vue';
  195. import workReportTable from './components/tables/workReportTable.vue';
  196. import qualityWorkOrderTable from './components/tables/qualityWorkOrderTable.vue';
  197. import wmsOutInt from './components/tables/wmsOutInt.vue';
  198. import batchRecordTable from './components/tables/batchRecordTable.vue';
  199. import deviceBatchRecordTable from './components/tables/deviceBatchRecordTable.vue';
  200. import craftFilesTable from './components/tables/craftFilesTable.vue';
  201. import qualityInspection from './components/tables/qualityInspection.vue';
  202. export default {
  203. components: {
  204. seekPage,
  205. workOrderTable,
  206. materialTable,
  207. materialReturnTable,
  208. workReportTable,
  209. qualityWorkOrderTable,
  210. wmsOutInt,
  211. batchRecordTable,
  212. deviceBatchRecordTable,
  213. craftFilesTable,
  214. qualityInspection
  215. },
  216. name: 'batchRecord',
  217. mixins: [dictMixins, tableColumnsMixin],
  218. data() {
  219. return {
  220. types: [
  221. {
  222. name: '生产工单',
  223. componentName: 'workOrderTable'
  224. },
  225. {
  226. name: '领料单',
  227. componentName: 'materialTable'
  228. },
  229. {
  230. name: '退料单',
  231. componentName: 'materialReturnTable'
  232. },
  233. {
  234. name: '报工',
  235. componentName: 'workReportTable'
  236. },
  237. {
  238. name: '质检工单',
  239. componentName: 'qualityWorkOrderTable'
  240. },
  241. {
  242. name: '入库单',
  243. componentName: 'wmsOutInt'
  244. },
  245. {
  246. name: '生产记录',
  247. componentName: 'batchRecordTable'
  248. },
  249. {
  250. name: '设备工单',
  251. componentName: 'deviceBatchRecordTable'
  252. },
  253. {
  254. name: '工艺文件',
  255. componentName: 'craftFilesTable'
  256. },
  257. {
  258. name: '首件两检',
  259. componentName: 'qualityInspection'
  260. }
  261. ],
  262. activeType: '生产工单',
  263. activeComponentName: 'workOrderTable',
  264. // 产品搜索条件
  265. productBody: {
  266. param: '',
  267. pageNum: 1,
  268. size: 10,
  269. // 创建开始时间和结束时间
  270. createTimeStart: '',
  271. createTimeEnd: ''
  272. },
  273. productButLoading: false,
  274. total: 0,
  275. // 批次号
  276. batchNos: [],
  277. // 产品列表
  278. productList: [],
  279. tableQuery: {
  280. productCode: '',
  281. batchNo: ''
  282. }
  283. };
  284. },
  285. computed: {},
  286. created() {
  287. // 设置 productBody.createTimeStart 和 productBody.createTimeEnd 为前一个月时间包含今天
  288. const endDate = new Date();
  289. const startDate = new Date();
  290. startDate.setMonth(startDate.getMonth() - 1);
  291. // 设置时间为 00:00:00
  292. startDate.setHours(0, 0, 0, 0);
  293. this.productBody.createTimeStart = this.$util.toDateString(
  294. startDate,
  295. 'yyyy-MM-dd HH:mm:ss'
  296. );
  297. this.productBody.createTimeEnd = this.$util.toDateString(
  298. endDate,
  299. 'yyyy-MM-dd HH:mm:ss'
  300. );
  301. this.getAllProductInWorkOrder();
  302. },
  303. methods: {
  304. // 刷新表格数据
  305. reload() {
  306. this.$refs.tableRef?.reload();
  307. },
  308. // 获取产品和批次号
  309. async getAllProductInWorkOrder() {
  310. try {
  311. this.productButLoading = true;
  312. const { list, count } = await getAllProductInWorkOrder(
  313. this.productBody
  314. );
  315. this.productList = list;
  316. console.log('this.productList', this.productList);
  317. this.productButLoading = false;
  318. this.total = count;
  319. } catch (error) {
  320. this.productButLoading = false;
  321. }
  322. },
  323. // 选择产品
  324. changeProductName(i) {
  325. this.tableQuery.productCode = i.productCode;
  326. // 设置批次号
  327. this.batchNos = i.batchNos;
  328. this.tableQuery.batchNo = '';
  329. // 刷新表格
  330. this.reload();
  331. },
  332. // 选择批次号
  333. changeBatchNo(i) {
  334. this.tableQuery.batchNo = i;
  335. this.reload();
  336. },
  337. // 选择批记录类型
  338. changeActiveType(i) {
  339. this.activeType = i.name;
  340. this.activeComponentName = i.componentName;
  341. this.reload();
  342. },
  343. resetSubmit() {
  344. this.productBody.param = '';
  345. this.productBody.createTimeStart = null;
  346. this.productBody.createTimeEnd = null;
  347. this.getAllProductInWorkOrder();
  348. },
  349. handleSizeChange(size) {
  350. this.productBody.size = size;
  351. this.getAllProductInWorkOrder();
  352. },
  353. handleCurrentChange(pageNum) {
  354. this.productBody.pageNum = pageNum;
  355. this.getAllProductInWorkOrder();
  356. },
  357. createTimeEndDateChange() {
  358. // 格式化 productBody.createTimeEnd 的时间为 23:59:59
  359. if (this.productBody.createTimeEnd) {
  360. const date = new Date(this.productBody.createTimeEnd);
  361. date.setHours(23, 59, 59);
  362. this.productBody.createTimeEnd = this.$util.toDateString(
  363. date,
  364. 'yyyy-MM-dd HH:mm:ss'
  365. );
  366. }
  367. }
  368. }
  369. };
  370. </script>
  371. <style lang="scss" scoped>
  372. .left-box {
  373. height: 100%;
  374. display: flex;
  375. .left-item {
  376. flex: 1;
  377. border-right: 1px solid #ededed;
  378. padding: 0 5px;
  379. width: 33.3%;
  380. position: relative;
  381. box-sizing: border-box;
  382. .title {
  383. text-align: center;
  384. font-size: 16px;
  385. padding: 10px 0;
  386. border-bottom: 1px solid #ededed;
  387. margin-bottom: 15px;
  388. }
  389. .list-box {
  390. margin-top: 10px;
  391. max-height: 78vh;
  392. overflow-y: auto;
  393. box-sizing: border-box;
  394. .list-item {
  395. padding: 10px 10px;
  396. border-bottom: 1px solid #ededed;
  397. font-size: 14px;
  398. cursor: pointer;
  399. word-break: break-all;
  400. }
  401. .active {
  402. background: #1890ff;
  403. color: #fff;
  404. }
  405. }
  406. .footer-box {
  407. width: 100%;
  408. height: 70px;
  409. position: absolute;
  410. left: 0;
  411. bottom: 0;
  412. z-index: 1;
  413. background: #fff;
  414. padding: 10px 0;
  415. :deep(.el-pagination__sizes) {
  416. display: block;
  417. margin-bottom: 10px;
  418. }
  419. }
  420. }
  421. }
  422. .productForm {
  423. .el-form-item {
  424. margin-bottom: 10px;
  425. }
  426. }
  427. .table-box {
  428. height: 85vh;
  429. overflow-y: auto;
  430. }
  431. </style>