index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. export default {
  202. components: {
  203. seekPage,
  204. workOrderTable,
  205. materialTable,
  206. materialReturnTable,
  207. workReportTable,
  208. qualityWorkOrderTable,
  209. wmsOutInt,
  210. batchRecordTable,
  211. deviceBatchRecordTable,
  212. craftFilesTable
  213. },
  214. name: 'batchRecord',
  215. mixins: [dictMixins, tableColumnsMixin],
  216. data() {
  217. return {
  218. types: [
  219. {
  220. name: '生产工单',
  221. componentName: 'workOrderTable'
  222. },
  223. {
  224. name: '领料单',
  225. componentName: 'materialTable'
  226. },
  227. {
  228. name: '退料单',
  229. componentName: 'materialReturnTable'
  230. },
  231. {
  232. name: '报工',
  233. componentName: 'workReportTable'
  234. },
  235. {
  236. name: '质检工单',
  237. componentName: 'qualityWorkOrderTable'
  238. },
  239. {
  240. name: '入库单',
  241. componentName: 'wmsOutInt'
  242. },
  243. {
  244. name: '生产记录',
  245. componentName: 'batchRecordTable'
  246. },
  247. {
  248. name: '设备工单',
  249. componentName: 'deviceBatchRecordTable'
  250. },
  251. {
  252. name: '工艺文件',
  253. componentName: 'craftFilesTable'
  254. }
  255. ],
  256. activeType: '生产工单',
  257. activeComponentName: 'workOrderTable',
  258. // 产品搜索条件
  259. productBody: {
  260. param: '',
  261. pageNum: 1,
  262. size: 10,
  263. // 创建开始时间和结束时间
  264. createTimeStart: '',
  265. createTimeEnd: ''
  266. },
  267. productButLoading: false,
  268. total: 0,
  269. // 批次号
  270. batchNos: [],
  271. // 产品列表
  272. productList: [],
  273. tableQuery: {
  274. productCode: '',
  275. batchNo: ''
  276. }
  277. };
  278. },
  279. computed: {},
  280. created() {
  281. // 设置 productBody.createTimeStart 和 productBody.createTimeEnd 为前一个月时间包含今天
  282. const endDate = new Date();
  283. const startDate = new Date();
  284. startDate.setMonth(startDate.getMonth() - 1);
  285. // 设置时间为 00:00:00
  286. startDate.setHours(0, 0, 0, 0);
  287. this.productBody.createTimeStart = this.$util.toDateString(
  288. startDate,
  289. 'yyyy-MM-dd HH:mm:ss'
  290. );
  291. this.productBody.createTimeEnd = this.$util.toDateString(
  292. endDate,
  293. 'yyyy-MM-dd HH:mm:ss'
  294. );
  295. this.getAllProductInWorkOrder();
  296. },
  297. methods: {
  298. // 刷新表格数据
  299. reload() {
  300. this.$refs.tableRef?.reload();
  301. },
  302. // 获取产品和批次号
  303. async getAllProductInWorkOrder() {
  304. try {
  305. this.productButLoading = true;
  306. const { list, count } = await getAllProductInWorkOrder(
  307. this.productBody
  308. );
  309. this.productList = list;
  310. console.log('this.productList', this.productList);
  311. this.productButLoading = false;
  312. this.total = count;
  313. } catch (error) {
  314. this.productButLoading = false;
  315. }
  316. },
  317. // 选择产品
  318. changeProductName(i) {
  319. this.tableQuery.productCode = i.productCode;
  320. // 设置批次号
  321. this.batchNos = i.batchNos;
  322. this.tableQuery.batchNo = '';
  323. // 刷新表格
  324. this.reload();
  325. },
  326. // 选择批次号
  327. changeBatchNo(i) {
  328. this.tableQuery.batchNo = i;
  329. this.reload();
  330. },
  331. // 选择批记录类型
  332. changeActiveType(i) {
  333. this.activeType = i.name;
  334. this.activeComponentName = i.componentName;
  335. this.reload();
  336. },
  337. resetSubmit() {
  338. this.productBody.param = '';
  339. this.productBody.createTimeStart = null;
  340. this.productBody.createTimeEnd = null;
  341. this.getAllProductInWorkOrder();
  342. },
  343. handleSizeChange(size) {
  344. this.productBody.size = size;
  345. this.getAllProductInWorkOrder();
  346. },
  347. handleCurrentChange(pageNum) {
  348. this.productBody.pageNum = pageNum;
  349. this.getAllProductInWorkOrder();
  350. },
  351. createTimeEndDateChange() {
  352. // 格式化 productBody.createTimeEnd 的时间为 23:59:59
  353. if (this.productBody.createTimeEnd) {
  354. const date = new Date(this.productBody.createTimeEnd);
  355. date.setHours(23, 59, 59);
  356. this.productBody.createTimeEnd = this.$util.toDateString(
  357. date,
  358. 'yyyy-MM-dd HH:mm:ss'
  359. );
  360. }
  361. }
  362. }
  363. };
  364. </script>
  365. <style lang="scss" scoped>
  366. .left-box {
  367. height: 100%;
  368. display: flex;
  369. .left-item {
  370. flex: 1;
  371. border-right: 1px solid #ededed;
  372. padding: 0 5px;
  373. width: 33.3%;
  374. position: relative;
  375. box-sizing: border-box;
  376. .title {
  377. text-align: center;
  378. font-size: 16px;
  379. padding: 10px 0;
  380. border-bottom: 1px solid #ededed;
  381. margin-bottom: 15px;
  382. }
  383. .list-box {
  384. margin-top: 10px;
  385. max-height: 78vh;
  386. overflow-y: auto;
  387. box-sizing: border-box;
  388. .list-item {
  389. padding: 10px 10px;
  390. border-bottom: 1px solid #ededed;
  391. font-size: 14px;
  392. cursor: pointer;
  393. word-break: break-all;
  394. }
  395. .active {
  396. background: #1890ff;
  397. color: #fff;
  398. }
  399. }
  400. .footer-box {
  401. width: 100%;
  402. height: 70px;
  403. position: absolute;
  404. left: 0;
  405. bottom: 0;
  406. z-index: 1;
  407. background: #fff;
  408. padding: 10px 0;
  409. :deep(.el-pagination__sizes) {
  410. display: block;
  411. margin-bottom: 10px;
  412. }
  413. }
  414. }
  415. }
  416. .productForm {
  417. .el-form-item {
  418. margin-bottom: 10px;
  419. }
  420. }
  421. .table-box {
  422. height: 85vh;
  423. overflow-y: auto;
  424. }
  425. </style>