detailedList.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div class="ele-body">
  3. <BOMSearch @search="reload" :statusOpt="statusOpt" />
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. :initLoad="false"
  9. class="dict-table"
  10. tool-class="ele-toolbar-actions"
  11. >
  12. <template v-slot:toolbar>
  13. <div class="toolbar_box">
  14. <div>
  15. <el-button type="primary" size="mini" @click="handleAdd"
  16. >新增</el-button
  17. >
  18. <el-button type="primary" size="mini" @click="handleAdd"
  19. >保存</el-button
  20. >
  21. </div>
  22. <div class="toolbar_box_right"
  23. ><span>基本数量</span>
  24. <el-input
  25. placeholder="请输入"
  26. v-model.number="attributeData.baseCount"
  27. >
  28. </el-input>
  29. <DictSelection dictName="计量单位" v-model="attributeData.unit"
  30. /></div>
  31. </div>
  32. </template>
  33. <template v-slot:dosage="{ row }">
  34. <el-input
  35. v-model="row.dosage"
  36. placeholder="请输入"
  37. size="mini"
  38. style="width: 68px"
  39. >
  40. </el-input>
  41. </template>
  42. <template v-slot:produceType="{ row }">
  43. <el-select
  44. v-model="row.produceType"
  45. filterable
  46. multiple
  47. collapse-tags
  48. class="ele-block"
  49. size="mini"
  50. >
  51. <el-option
  52. v-for="item in dictList"
  53. :key="item.value"
  54. :value="item.value"
  55. :label="item.label"
  56. ></el-option>
  57. </el-select>
  58. </template>
  59. <template v-slot:materielDesignation="{ row }">
  60. <el-input
  61. v-model="row.materielDesignation"
  62. placeholder="请输入物料代号"
  63. size="mini"
  64. style="width: 120px"
  65. >
  66. </el-input>
  67. </template>
  68. <template v-slot:supplierId="{ row }">
  69. <el-select
  70. v-model="row.supplierId"
  71. size="mini"
  72. clearable
  73. class="ele-block"
  74. filterable
  75. placeholder="请选择供应商"
  76. >
  77. <el-option
  78. v-for="(item, index) in gysList"
  79. :key="item.id + index"
  80. :value="item.id"
  81. :label="item.name"
  82. ></el-option>
  83. </el-select>
  84. </template>
  85. <template v-slot:factories="{ row }">
  86. <el-input
  87. v-model="row.factories"
  88. placeholder="请输入生产厂家"
  89. size="mini"
  90. style="width: 120px"
  91. >
  92. </el-input>
  93. </template>
  94. <!-- 表头工具栏 -->
  95. <template v-slot:action="{ row }">
  96. <el-link
  97. type="danger"
  98. :underline="false"
  99. icon="el-icon-delete"
  100. @click="handleDel(row)"
  101. >
  102. 删除
  103. </el-link>
  104. </template>
  105. </ele-pro-table>
  106. <bomTreeDialog ref="bomTreeDialogRef" @reload="bomClose" />
  107. </div>
  108. </template>
  109. <script>
  110. import BOMSearch from './BOM-search.vue';
  111. import {
  112. getBomPageCategoryId,
  113. contactList,
  114. deleteBomTreeList
  115. } from '@/api/material/BOM';
  116. import { getByCode } from '@/api/system/dictionary-data';
  117. import bomTreeDialog from './bomTreeDialog.vue';
  118. export default {
  119. name: 'SystemDictionary',
  120. components: { BOMSearch, bomTreeDialog },
  121. data() {
  122. return {
  123. // 表格列配置
  124. columns: [
  125. {
  126. label: '序号',
  127. columnKey: 'index',
  128. type: 'index',
  129. width: 55,
  130. align: 'center',
  131. showOverflowTooltip: true
  132. },
  133. {
  134. prop: 'categoryCode',
  135. label: '编码',
  136. showOverflowTooltip: true,
  137. width: 120
  138. },
  139. {
  140. prop: 'categoryName',
  141. label: '名称',
  142. width: 150
  143. },
  144. {
  145. prop: 'brandNum',
  146. label: '牌号'
  147. },
  148. {
  149. prop: 'modelType',
  150. label: '型号',
  151. align: 'center',
  152. showOverflowTooltip: true
  153. },
  154. {
  155. prop: 'specification',
  156. label: '规格',
  157. align: 'center',
  158. showOverflowTooltip: true
  159. },
  160. {
  161. prop: 'dosage',
  162. slot: 'dosage',
  163. label: '用量',
  164. width: 100
  165. },
  166. {
  167. prop: 'measuringUnit',
  168. label: '计量单位',
  169. showOverflowTooltip: true
  170. },
  171. {
  172. prop: 'produceType',
  173. slot: 'produceType',
  174. label: '生产类型',
  175. width: 160
  176. },
  177. {
  178. prop: 'materielDesignation',
  179. slot: 'materielDesignation',
  180. label: '物料代号',
  181. width: 150
  182. },
  183. {
  184. prop: 'supplierId',
  185. slot: 'supplierId',
  186. label: '供应商',
  187. width: 150
  188. },
  189. {
  190. prop: 'factories',
  191. slot: 'factories',
  192. label: '生产厂家',
  193. width: 180
  194. },
  195. {
  196. prop: 'versions',
  197. label: '版本'
  198. },
  199. {
  200. prop: 'status ',
  201. label: '状态',
  202. formatter: (row) => {
  203. return this.statusOpt[+row.status];
  204. }
  205. },
  206. {
  207. prop: 'createName',
  208. label: '创建人',
  209. showOverflowTooltip: true
  210. },
  211. {
  212. prop: 'createTime',
  213. label: '创建日期',
  214. width: 160
  215. },
  216. {
  217. action: 'action',
  218. slot: 'action',
  219. fixed: 'right',
  220. label: '操作',
  221. width: 120
  222. }
  223. ],
  224. statusOpt: {
  225. '': '全部',
  226. 0: '已停用',
  227. 1: '已发布'
  228. },
  229. gysList: [],
  230. attrObj: {},
  231. newTreeId: null,
  232. dictList: []
  233. };
  234. },
  235. created() {
  236. this.getDictList('productionType');
  237. this.getContactList();
  238. },
  239. mounted() {},
  240. props: {
  241. attributeData: {
  242. type: Object,
  243. default: {}
  244. },
  245. treeId: {
  246. type: String,
  247. default: ''
  248. }
  249. },
  250. watch: {
  251. attributeData(val) {
  252. this.attrObj = val;
  253. this.$refs.table.setData([]);
  254. this.$nextTick(() => {
  255. this.$refs.table.reload({
  256. pageNum: 1
  257. });
  258. });
  259. },
  260. treeId(val) {
  261. this.newTreeId = val;
  262. }
  263. },
  264. methods: {
  265. /* 表格数据源 */
  266. datasource({ where, page, limit }) {
  267. if (!this.attrObj.id) {
  268. return false;
  269. }
  270. return getBomPageCategoryId({
  271. ...where,
  272. pageNum: page,
  273. size: limit,
  274. id: this.attrObj.id,
  275. bomType: this.attrObj.bomType
  276. });
  277. },
  278. /* 刷新表格 */
  279. reload(where) {
  280. this.$refs.table.reload({ where });
  281. },
  282. async getDictList(code) {
  283. let { data: res } = await getByCode(code);
  284. this.dictList = res.map((item) => {
  285. let values = Object.keys(item);
  286. return {
  287. value: Number(values[0]),
  288. label: item[values[0]]
  289. };
  290. });
  291. },
  292. getContactList() {
  293. let param = {
  294. pageNum: 1,
  295. type: 2,
  296. size: -1,
  297. status: 1
  298. };
  299. contactList(param).then((res) => {
  300. this.gysList = res.list;
  301. });
  302. },
  303. handleAdd() {
  304. // 打开树形对话框
  305. this.$refs.bomTreeDialogRef.open(
  306. this.attributeData.bomType,
  307. this.attributeData.versions,
  308. this.attributeData.categoryId,
  309. this.newTreeId
  310. );
  311. },
  312. bomClose() {
  313. this.$nextTick(() => {
  314. this.$refs.table.reload({
  315. pageNum: 1
  316. });
  317. });
  318. },
  319. handleDel(row) {
  320. this.$confirm('是否确认删除?', '提示', {
  321. confirmButtonText: '确定',
  322. cancelButtonText: '取消',
  323. type: 'warning'
  324. })
  325. .then(() => {
  326. deleteBomTreeList([row.id]).then((msg) => {
  327. this.$message.success('删除' + msg);
  328. this.$refs.table.reload({
  329. pageNum: 1
  330. });
  331. });
  332. })
  333. .finally(() => {});
  334. }
  335. }
  336. };
  337. </script>
  338. <style lang="scss" scoped>
  339. .ele-body {
  340. height: 100%;
  341. ::v-deep .el-card {
  342. height: 100%;
  343. .el-card__body {
  344. height: 100%;
  345. display: flex;
  346. flex-direction: column;
  347. .dict-table {
  348. flex: 1;
  349. overflow: hidden;
  350. display: flex;
  351. flex-direction: column;
  352. .el-table {
  353. flex: 1;
  354. overflow-y: auto;
  355. }
  356. }
  357. }
  358. }
  359. }
  360. .toolbar_box {
  361. display: flex;
  362. justify-content: space-between;
  363. align-items: center;
  364. .toolbar_box_right {
  365. display: flex;
  366. align-items: center;
  367. justify-content: center;
  368. margin-right: 10px;
  369. > span {
  370. width: 150px;
  371. }
  372. > div {
  373. margin-left: 10px;
  374. }
  375. }
  376. }
  377. </style>