ProductModal.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <el-dialog :title="title" :visible.sync="visible" v-if="visible" :before-close="handleClose"
  3. :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="75%">
  4. <el-card shadow="never">
  5. <ProductSearch @search="reload" ref="searchRef" />
  6. <ele-split-layout width="244px" allow-collapse :right-style="{ overflow: 'hidden' }">
  7. <div class="ele-border-lighter split-layout-right-content">
  8. <AssetTree ref="assetTreeRef" :id="categoryLevelId" @handleNodeClick="handleNodeClick" />
  9. </div>
  10. <!-- 表格 -->
  11. <template v-slot:content>
  12. <ele-pro-table ref="table" :columns="isLedger ? columns2 : columns" :datasource="datasource" row-key="id"
  13. height="calc(100vh - 350px)" class="dict-table" @cell-click="cellClick">
  14. <!-- 表头工具栏 -->
  15. <template v-slot:action="{ row }">
  16. <el-radio class="radio" v-model="radio" :label="row.id"><i></i></el-radio>
  17. </template>
  18. </ele-pro-table>
  19. </template>
  20. </ele-split-layout>
  21. </el-card>
  22. <div class="btns">
  23. <el-button type="primary" size="small" @click="selected">选择</el-button>
  24. <el-button size="small" @click="handleClose">关闭</el-button>
  25. </div>
  26. </el-dialog>
  27. </template>
  28. <script>
  29. import AssetTree from '@/components/AssetTree';
  30. import ProductSearch from './product-search.vue'
  31. import { getMaterialList } from '@/api/material/list.js';
  32. import { getAssetList } from '@/api/ledgerAssets/index'
  33. export default {
  34. components: { AssetTree, ProductSearch },
  35. props: {
  36. isLedger: {
  37. type: Boolean,
  38. default: false
  39. }
  40. },
  41. data() {
  42. return {
  43. visible: false,
  44. // 表格列配置
  45. columns: [
  46. {
  47. action: 'action',
  48. slot: 'action',
  49. align: 'center',
  50. label: '选择',
  51. fixed:'left'
  52. },
  53. {
  54. columnKey: 'index',
  55. type: 'index',
  56. width: 45,
  57. align: 'center',
  58. reserveSelection: true
  59. },
  60. {
  61. prop: 'code',
  62. label: '编码'
  63. },
  64. {
  65. prop: 'name',
  66. label: '名称',
  67. showOverflowTooltip: true
  68. },
  69. {
  70. prop: 'brandNum',
  71. label: '牌号'
  72. },
  73. {
  74. prop: 'modelType',
  75. label: '型号',
  76. align: 'center',
  77. showOverflowTooltip: true
  78. },
  79. {
  80. prop: 'specification',
  81. label: '规格',
  82. align: 'center',
  83. showOverflowTooltip: true
  84. },
  85. {
  86. prop: 'measuringUnit',
  87. label: '计量单位',
  88. showOverflowTooltip: true,
  89. minWidth: 90
  90. },
  91. {
  92. prop: 'weightUnit',
  93. label: '重量单位',
  94. showOverflowTooltip: true,
  95. minWidth: 90
  96. },
  97. {
  98. prop: 'roughWeight',
  99. label: '毛重',
  100. showOverflowTooltip: true,
  101. minWidth: 90
  102. },
  103. {
  104. prop: 'netWeight',
  105. label: '净重',
  106. showOverflowTooltip: true,
  107. minWidth: 90
  108. },
  109. {
  110. prop: 'packingUnit',
  111. align: 'center',
  112. label: '包装单位',
  113. showOverflowTooltip: true
  114. },
  115. {
  116. prop: 'categoryLevelPath',
  117. label: '分类',
  118. align: 'center',
  119. showOverflowTooltip: true
  120. },
  121. ],
  122. columns2: [
  123. {
  124. action: 'action',
  125. slot: 'action',
  126. align: 'center',
  127. label: '选择',
  128. fixed:'left'
  129. },
  130. {
  131. columnKey: 'index',
  132. type: 'index',
  133. label: '序号',
  134. width: 55,
  135. align: 'center',
  136. showOverflowTooltip: true,
  137. fixed: 'left'
  138. },
  139. {
  140. prop: 'fixCode',
  141. label: '固资编码',
  142. showOverflowTooltip: true,
  143. minWidth: 110
  144. },
  145. {
  146. prop: 'code',
  147. label: '编码'
  148. },
  149. {
  150. prop: 'name',
  151. label: '名称',
  152. showOverflowTooltip: true
  153. },
  154. {
  155. prop: 'codeNumber',
  156. label: '编号',
  157. showOverflowTooltip: true,
  158. minWidth: 110
  159. },
  160. {
  161. prop: 'category.modelType',
  162. label: '型号',
  163. showOverflowTooltip: true,
  164. minWidth: 110
  165. },
  166. {
  167. prop: 'category.specification',
  168. label: '规格',
  169. showOverflowTooltip: true,
  170. minWidth: 110
  171. },
  172. {
  173. prop: 'pathName',
  174. label: '位置',
  175. showOverflowTooltip: true,
  176. minWidth: 110,
  177. formatter: (_row) => {
  178. return _row.position[0].pathName;
  179. }
  180. },
  181. {
  182. prop: 'source',
  183. label: '生命周期',
  184. showOverflowTooltip: true,
  185. minWidth: 110
  186. },
  187. ],
  188. title: null,
  189. categoryLevelId: null,
  190. radio: null,
  191. idx: null,
  192. isCategory: true
  193. }
  194. },
  195. watch: {
  196. },
  197. methods: {
  198. /* 表格数据源 */
  199. datasource({ page, where, limit }) {
  200. let URL = this.isLedger ? getAssetList : getMaterialList
  201. if (this.isCategory) {
  202. return URL({
  203. ...where,
  204. pageNum: page,
  205. size: limit,
  206. categoryLevelId: this.categoryLevelId
  207. });
  208. } else {
  209. return URL({
  210. ...where,
  211. pageNum: page,
  212. size: limit,
  213. });
  214. }
  215. },
  216. handleNodeClick(data) {
  217. this.isCategory = true
  218. this.categoryLevelId = data.id;
  219. this.$refs.table.reload({ pageNum: 1, where: {} });
  220. this.$refs.searchRef.reset2()
  221. },
  222. /* 刷新表格 */
  223. reload(where) {
  224. this.isCategory = false
  225. this.$refs.table.reload({ pageNum: 1, where: where });
  226. },
  227. open(item, title, categoryLevelId, idx) {
  228. if (item) {
  229. this.title = title
  230. this.categoryLevelId = categoryLevelId
  231. this.idx = idx
  232. this.current = {
  233. id: item.categoryId,
  234. name: item.categoryName,
  235. code: item.categoryCode
  236. }
  237. this.radio = item.categoryId
  238. }
  239. this.visible = true
  240. },
  241. // 单击获取id
  242. cellClick(row) {
  243. this.current = row
  244. this.radio = row.id
  245. },
  246. handleClose() {
  247. this.visible = false
  248. this.current = null
  249. this.radio = ''
  250. },
  251. selected() {
  252. if (!this.current) {
  253. return this.$message.warning('请选择工作中心')
  254. }
  255. this.$emit('changeProduct', this.title, this.current, this.idx)
  256. this.handleClose()
  257. },
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .tree_col {
  263. border: 1px solid #eee;
  264. padding: 10px 0;
  265. box-sizing: border-box;
  266. height: 500px;
  267. overflow: auto;
  268. }
  269. .table_col {
  270. padding-left: 10px;
  271. ::v-deep .el-table th.el-table__cell {
  272. background: #f2f2f2;
  273. }
  274. }
  275. .pagination {
  276. text-align: right;
  277. padding: 10px 0;
  278. }
  279. .btns {
  280. text-align: center;
  281. padding: 10px 0;
  282. }
  283. .topsearch {
  284. margin-bottom: 15px;
  285. }
  286. </style>