index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <ele-split-layout
  5. width="460px"
  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-input
  13. placeholder="搜索"
  14. :suffix-icon="productBody.param ? '' : 'el-icon-search'"
  15. v-model="productBody.param"
  16. @input="handleInput"
  17. clearable
  18. ></el-input>
  19. <div class="list-box">
  20. <div
  21. class="list-item"
  22. v-for="i in productList"
  23. :key="i.productName + i.productCode"
  24. :class="{ active: i.productName == tableQuery.param }"
  25. @click="changeProductName(i)"
  26. >
  27. {{ i.productName }}
  28. </div>
  29. </div>
  30. </div>
  31. <div class="left-item">
  32. <div class="title">批次号</div>
  33. <div v-if="batchNos.length > 0" class="list-box">
  34. <div class="list-item" v-for="i in batchNos" :key="i">
  35. <div> {{ i ? i : '暂无批次号' }}</div>
  36. </div>
  37. </div>
  38. <div v-else class="list-box">
  39. <div class="list-item" style="text-align: center; color: #888">
  40. 请先选择产品
  41. </div>
  42. </div>
  43. </div>
  44. <div class="left-item">
  45. <div class="title">批记录类型</div>
  46. <div class="list-box">
  47. <div
  48. class="list-item"
  49. v-for="i in types"
  50. :key="i.name"
  51. :class="{ active: activeType == i.name }"
  52. @click="changeActiveType(i)"
  53. >
  54. {{ i.name }}
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <template v-slot:content>
  60. <div>
  61. <seek-page :seekList="seekList" @search="search"></seek-page>
  62. <ele-pro-table
  63. ref="table"
  64. row-key="workOrderId"
  65. :columns="columns"
  66. :datasource="datasource"
  67. cache-key="batch-record-list"
  68. autoAmendPage
  69. >
  70. </ele-pro-table>
  71. </div>
  72. </template>
  73. </ele-split-layout>
  74. </el-card>
  75. </div>
  76. </template>
  77. <script>
  78. import dictMixins from '@/mixins/dictMixins';
  79. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  80. import seekPage from '@/components/common/seekPage.vue';
  81. import { getAllProductInWorkOrder } from '@/api/produce/workOrder';
  82. import { debounce } from '@/utils/util.js';
  83. import { batchRecordPage } from '@/api/workOrderList';
  84. export default {
  85. components: { seekPage },
  86. name: 'batchRecord',
  87. mixins: [dictMixins, tableColumnsMixin],
  88. data() {
  89. return {
  90. columns: [
  91. {
  92. width: 50,
  93. type: 'index',
  94. columnKey: 'index',
  95. align: 'center',
  96. label: '序号'
  97. },
  98. {
  99. prop: 'workOrderName',
  100. label: '单据名称'
  101. },
  102. {
  103. prop: '',
  104. label: '单据编码'
  105. },
  106. {
  107. prop: 'status',
  108. label: '单据状态'
  109. },
  110. {
  111. prop: 'approveStatus',
  112. label: '审核状态'
  113. }
  114. ],
  115. types: [
  116. {
  117. name: '生产工单'
  118. },
  119. {
  120. name: '领料单'
  121. },
  122. {
  123. name: '退票单'
  124. },
  125. {
  126. name: '报工'
  127. },
  128. {
  129. name: '质检工单'
  130. },
  131. {
  132. name: '入库单'
  133. },
  134. {
  135. name: '生产记录'
  136. },
  137. {
  138. name: '设备工单'
  139. },
  140. {
  141. name: '工艺文件'
  142. }
  143. ],
  144. activeType: '生产工单',
  145. // 产品搜索条件
  146. productBody: {
  147. param: '',
  148. pageNum: 1,
  149. size: 999
  150. },
  151. // 批次号
  152. batchNos: [],
  153. // 产品列表
  154. productList: [],
  155. tableQuery: {
  156. param: '',
  157. batchNo: '',
  158. type: ''
  159. }
  160. };
  161. },
  162. computed: {
  163. seekList() {
  164. return [
  165. {
  166. label: '单据编码:',
  167. value: 'workOrderCode',
  168. type: 'input',
  169. placeholder: '请输入'
  170. },
  171. {
  172. label: '单据名称:',
  173. value: 'workOrderName',
  174. type: 'input',
  175. placeholder: '请输入'
  176. }
  177. ];
  178. },
  179. /* 表格数据源 */
  180. datasource({ page, limit, where, order }) {
  181. return () => {
  182. const body = { ...where, ...order, page, limit, ...this.tableQuery };
  183. // 根据类型查询不同的api
  184. switch (this.activeType) {
  185. case '生产工单':
  186. return batchRecordPage(body);
  187. default:
  188. return [];
  189. }
  190. };
  191. }
  192. },
  193. created() {
  194. this.getAllProductInWorkOrder();
  195. },
  196. methods: {
  197. reload(where) {
  198. this.$refs.table.reload({
  199. where,
  200. ...this.tableQuery
  201. });
  202. },
  203. // 刷新表格数据
  204. search(where) {
  205. this.reload(where);
  206. },
  207. // 获取产品和批次号
  208. async getAllProductInWorkOrder() {
  209. const { list } = await getAllProductInWorkOrder(this.productBody);
  210. this.productList = list;
  211. console.log('this.productList', this.productList);
  212. },
  213. // 搜索产品
  214. handleInput: debounce(function (e) {
  215. this.getAllProductInWorkOrder();
  216. }, 500),
  217. // 选择产品
  218. changeProductName(i) {
  219. this.tableQuery.param = i.productName;
  220. // 设置批次号
  221. this.batchNos = i.batchNos;
  222. // 刷新表格
  223. this.reload();
  224. },
  225. // 选择批记录类型
  226. changeActiveType(i) {
  227. this.activeType = i.name;
  228. this.reload();
  229. }
  230. }
  231. };
  232. </script>
  233. <style lang="scss" scoped>
  234. .left-box {
  235. display: flex;
  236. .left-item {
  237. flex: 1;
  238. border-right: 1px solid #ededed;
  239. min-height: 80vh;
  240. padding: 0 5px;
  241. .title {
  242. text-align: center;
  243. font-size: 16px;
  244. padding: 10px 0;
  245. border-bottom: 1px solid #ededed;
  246. margin-bottom: 15px;
  247. }
  248. .list-box {
  249. margin-top: 10px;
  250. max-height: 80vh;
  251. overflow-y: auto;
  252. box-sizing: border-box;
  253. .list-item {
  254. padding: 15px 10px;
  255. border-bottom: 1px solid #ededed;
  256. font-size: 14px;
  257. cursor: pointer;
  258. word-break: break-all;
  259. }
  260. .active {
  261. background: #1890ff;
  262. color: #fff;
  263. }
  264. }
  265. }
  266. }
  267. </style>