plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

560 lines
17 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="mod-config">
  3. <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
  4. <el-form-item :label="'商品组编码'">
  5. <el-input v-model="searchData.productGroupId" clearable style="width: 120px"></el-input>
  6. </el-form-item>
  7. <el-form-item :label="'商品组名称'">
  8. <el-input v-model="searchData.productGroupName" clearable style="width: 120px"></el-input>
  9. </el-form-item>
  10. <el-form-item :label="'是否在用'">
  11. <el-select clearable v-model="searchData.active" style="width: 120px">
  12. <el-option label="是" value="Y"></el-option>
  13. <el-option label="否" value="N"></el-option>
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item :label="'商品组'">
  17. <el-select clearable v-model="searchData.type" style="width: 120px">
  18. <el-option label="商品组1" value="1"></el-option>
  19. <el-option label="商品组2" value="2"></el-option>
  20. <el-option label="商品组3" value="3"></el-option>
  21. <el-option label="商品组4" value="4"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item :label="' '">
  25. <el-button type="primary" @click="getDataList()">查询</el-button>
  26. <el-button type="primary" @click="addModal()">新增</el-button>
  27. <download-excel
  28. :fields="fields()"
  29. :data="exportData"
  30. type="xls"
  31. :name="exportName"
  32. :header="exportHeader"
  33. :footer="exportFooter"
  34. :fetch="createExportData"
  35. :before-generate="startDownload"
  36. :before-finish="finishDownload"
  37. worksheet="导出信息"
  38. class="el-button el-button--primary el-button--medium">
  39. {{ "导出" }}
  40. </download-excel>
  41. </el-form-item>
  42. </el-form>
  43. <el-table
  44. :height="height"
  45. :data="dataList"
  46. border
  47. v-loading="dataListLoading"
  48. style="width: 100%;">
  49. <el-table-column
  50. v-for="(item,index) in columnList" :key="index"
  51. :sortable="item.columnSortable"
  52. :prop="item.columnProp"
  53. :header-align="item.headerAlign"
  54. :show-overflow-tooltip="item.showOverflowTooltip"
  55. :align="item.align"
  56. :fixed="item.fixed==''?false:item.fixed"
  57. :min-width="item.columnWidth"
  58. :label="item.columnLabel">
  59. <template slot-scope="scope">
  60. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  61. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column
  65. fixed="right"
  66. header-align="center"
  67. align="center"
  68. width="160"
  69. label="操作">
  70. <template slot-scope="scope">
  71. <a type="text" size="small" @click="updateModal(scope.row)">修改</a>
  72. <a type="text" size="small" @click="delModal(scope.row)">删除</a>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <!-- 分页栏 -->
  77. <el-pagination
  78. @size-change="sizeChangeHandle"
  79. @current-change="currentChangeHandle"
  80. :current-page="pageIndex"
  81. :page-sizes="[20, 50, 100, 200, 500]"
  82. :page-size="pageSize"
  83. :total="totalPage"
  84. layout="total, sizes, prev, pager, next, jumper">
  85. </el-pagination>
  86. <el-dialog :title="modalData.title" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="495px">
  87. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  88. <el-form-item label="商品组编码" prop="productGroupId" :rules="rules.productGroupId">
  89. <el-input v-model="modalData.productGroupId" :disabled="modalDisableFlag" style="width: 221px"></el-input>
  90. </el-form-item>
  91. <el-form-item label="商品组名称" prop="productGroupName" :rules="rules.productGroupName">
  92. <el-input v-model="modalData.productGroupName" style="width: 221px"></el-input>
  93. </el-form-item>
  94. </el-form>
  95. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  96. <el-form-item label="是否在用" prop="active" :rules="rules.active">
  97. <el-select v-model="modalData.active" style="width: 221px">
  98. <el-option label="是" value="Y"></el-option>
  99. <el-option label="否" value="N"></el-option>
  100. </el-select>
  101. </el-form-item>
  102. </el-form>
  103. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  104. <el-form-item label="商品组" prop="type" :rules="rules.type">
  105. <el-select v-model="modalData.type" style="width: 221px">
  106. <el-option label="商品组1" value="1"></el-option>
  107. <el-option label="商品组2" value="2"></el-option>
  108. <el-option label="商品组3" value="3"></el-option>
  109. <el-option label="商品组4" value="4"></el-option>
  110. </el-select>
  111. </el-form-item>
  112. </el-form>
  113. <el-footer style="height:30px;margin-top: 20px;text-align:center">
  114. <el-button type="primary" @click="saveData()">保存</el-button>
  115. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  116. </el-footer>
  117. </el-dialog>
  118. <!-- chooseList模态框 -->
  119. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  120. </div>
  121. </template>
  122. <script>
  123. import {
  124. productGroupInformationSearch, // 商品信息列表查询
  125. productGroupInformationSave, // 商品信息新增
  126. productGroupInformationEdit, // 商品信息编辑
  127. productGroupInformationDelete // 商品信息删除
  128. } from '@/api/part/productGroupInformation.js'
  129. import Chooselist from '@/views/modules/common/Chooselist'
  130. import productGroupInformation from './productGroupInformation'
  131. export default {
  132. components: {
  133. Chooselist
  134. },
  135. watch: {
  136. searchData: {
  137. deep: true,
  138. handler: function (newV, oldV) {
  139. this.searchData.productGroupId = this.searchData.productGroupId.toUpperCase()
  140. }
  141. },
  142. modalData: {
  143. deep: true,
  144. handler: function (newV, oldV) {
  145. this.modalData.productGroupId = this.modalData.productGroupId.toUpperCase()
  146. }
  147. }
  148. },
  149. data () {
  150. return {
  151. // 导出
  152. exportData: [],
  153. exportName: '商品组' + this.dayjs().format('YYYYMMDDHHmmss'),
  154. exportHeader: ['商品'],
  155. exportFooter: [],
  156. resultList: [],
  157. // ======== 行高 ========
  158. height: 200,
  159. // ======== 分页 ========
  160. pageIndex: 1,
  161. pageSize: 50,
  162. totalPage: 0,
  163. // 条件查询
  164. searchData: {
  165. site: this.$store.state.user.site,
  166. productGroupId: '',
  167. productGroupName: '',
  168. active: '',
  169. type: '',
  170. page: 1,
  171. limit: 10
  172. },
  173. // 其它
  174. dataListLoading: false,
  175. modalData: {
  176. flag: '',
  177. title: '',
  178. site: this.$store.state.user.site,
  179. productGroupId: '',
  180. productGroupName: '',
  181. active: '',
  182. type: ''
  183. },
  184. // ======== 数据列表 ========
  185. dataList: [],
  186. // 展示列集
  187. columnList: [
  188. {
  189. userId: this.$store.state.user.name,
  190. functionId: 100007,
  191. serialNumber: '100007Table1ProductGroupId',
  192. tableId: "100007Table1",
  193. tableName: "商品组信息表",
  194. columnProp: 'productGroupId',
  195. headerAlign: "center",
  196. align: "left",
  197. columnLabel: '商品组编码',
  198. columnHidden: false,
  199. columnImage: false,
  200. columnSortable: false,
  201. sortLv: 0,
  202. status: true,
  203. fixed: '',
  204. },
  205. {
  206. userId: this.$store.state.user.name,
  207. functionId: 100007,
  208. serialNumber: '100007Table1ProductGroupName',
  209. tableId: "100007Table1",
  210. tableName: "商品组信息表",
  211. columnProp: 'productGroupName',
  212. headerAlign: "center",
  213. align: "left",
  214. columnLabel: '商品组名称',
  215. columnHidden: false,
  216. columnImage: false,
  217. columnSortable: false,
  218. sortLv: 0,
  219. status: true,
  220. fixed: '',
  221. },
  222. {
  223. functionId: 100007,
  224. serialNumber: '100007Table1Active',
  225. tableId: '100007Table1',
  226. tableName: '商品组信息表',
  227. columnProp: 'active',
  228. headerAlign: 'center',
  229. align: 'center',
  230. columnLabel: '是否在用',
  231. columnHidden: false,
  232. columnImage: false,
  233. columnSortable: false,
  234. sortLv: 0,
  235. status: true,
  236. fixed: '',
  237. columnWidth: 120
  238. },
  239. {
  240. functionId: 100007,
  241. serialNumber: '100007Table1Type',
  242. tableId: "100007Table1",
  243. tableName: "商品组信息表",
  244. columnProp: "type",
  245. headerAlign: "center",
  246. align: "center",
  247. columnLabel: '商品组',
  248. columnHidden: false,
  249. columnImage: false,
  250. columnSortable: false,
  251. sortLv: 0,
  252. status: true,
  253. fixed: '',
  254. columnWidth: 120
  255. },
  256. {
  257. userId: this.$store.state.user.name,
  258. functionId: 100007,
  259. serialNumber: '100007Table1CreateDate',
  260. tableId: '100007Table1',
  261. tableName: '商品组信息表',
  262. columnProp: 'createDate',
  263. headerAlign: 'center',
  264. align: 'center',
  265. columnLabel: '创建时间',
  266. columnHidden: false,
  267. columnImage: false,
  268. columnSortable: false,
  269. sortLv: 0,
  270. status: true,
  271. fixed: '',
  272. },
  273. {
  274. userId: this.$store.state.user.name,
  275. functionId: 100007,
  276. serialNumber: '100007Table1CreateBy',
  277. tableId: "100007Table1",
  278. tableName: "商品组信息表",
  279. columnProp: 'createBy',
  280. headerAlign: "center",
  281. align: "center",
  282. columnLabel: '创建人',
  283. columnHidden: false,
  284. columnImage: false,
  285. columnSortable: false,
  286. sortLv: 0,
  287. status: true,
  288. fixed: '',
  289. },
  290. {
  291. userId: this.$store.state.user.name,
  292. functionId: 100007,
  293. serialNumber: '100007Table1UpdateDate',
  294. tableId: "100007Table1",
  295. tableName: "商品组信息表",
  296. columnProp: 'updateDate',
  297. headerAlign: "center",
  298. align: "center",
  299. columnLabel: '更新时间',
  300. columnHidden: false,
  301. columnImage: false,
  302. columnSortable: false,
  303. sortLv: 0,
  304. status: true,
  305. fixed: '',
  306. },
  307. {
  308. userId: this.$store.state.user.name,
  309. functionId: 100007,
  310. serialNumber: '100007Table1UpdateBy',
  311. tableId: "100007Table1",
  312. tableName: "商品组信息表",
  313. columnProp: 'updateBy',
  314. headerAlign: "center",
  315. align: "center",
  316. columnLabel: '更新人',
  317. columnHidden: false,
  318. columnImage: false,
  319. columnSortable: false,
  320. sortLv: 0,
  321. status: true,
  322. fixed: '',
  323. },
  324. ],
  325. rules:{
  326. productGroupId:[
  327. {
  328. required: true,
  329. message: ' ',
  330. trigger: 'change'
  331. }
  332. ],
  333. productGroupName:[
  334. {
  335. required: true,
  336. message: ' ',
  337. trigger: 'change'
  338. }
  339. ],
  340. active:[
  341. {
  342. required: true,
  343. message: ' ',
  344. trigger: 'change'
  345. }
  346. ],
  347. type:[
  348. {
  349. required: true,
  350. message: ' ',
  351. trigger: 'change'
  352. }
  353. ],
  354. },
  355. // ======== 模态框开关控制 ========
  356. modalFlag: false,
  357. modalDisableFlag: false,
  358. }
  359. },
  360. mounted () {
  361. this.$nextTick(() => {
  362. this.height = window.innerHeight - 180
  363. })
  364. },
  365. created () {
  366. this.getDataList()
  367. },
  368. methods: {
  369. // 每页数
  370. sizeChangeHandle (val) {
  371. this.pageSize = val
  372. this.pageIndex = 1
  373. this.getDataList()
  374. },
  375. // 当前页
  376. currentChangeHandle (val) {
  377. this.pageIndex = val
  378. this.getDataList()
  379. },
  380. //导出excel
  381. async createExportData() {
  382. this.searchData.limit = -1
  383. this.searchData.page = 1
  384. await productGroupInformationSearch(this.searchData).then(({data}) => {
  385. this.exportList= data.page.list;
  386. })
  387. return this.exportList;
  388. },
  389. startDownload() {
  390. },
  391. finishDownload() {
  392. },
  393. fields() {
  394. let json = "{"
  395. this.columnList.forEach((item, index) => {
  396. if (index == this.columnList.length - 1) {
  397. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  398. } else {
  399. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  400. }
  401. })
  402. json += "}"
  403. let s = eval("(" + json + ")")
  404. return s
  405. },
  406. // 导出 end
  407. // 获取数据列表
  408. getDataList () {
  409. this.searchData.limit = this.pageSize
  410. this.searchData.page = this.pageIndex
  411. productGroupInformationSearch(this.searchData).then(({data}) => {
  412. if (data.code === 0) {
  413. this.dataList = data.page.list
  414. this.pageIndex = data.page.currPage
  415. this.pageSize = data.page.pageSize
  416. this.totalPage = data.page.totalCount
  417. }
  418. this.dataListLoading = false
  419. })
  420. },
  421. addModal(){
  422. this.modalData = {
  423. flag: '1',
  424. title: '商品组新增',
  425. site: this.$store.state.user.site,
  426. createBy: this.$store.state.user.name,
  427. productGroupId: '',
  428. productGroupName: '',
  429. active: 'Y',
  430. type: ''
  431. }
  432. this.modalDisableFlag = false
  433. this.modalFlag = true
  434. },
  435. /**
  436. * 商品信息编辑模态框
  437. * @param row
  438. */
  439. updateModal (row) {
  440. this.modalData = {
  441. flag: '2',
  442. title: '商品组编辑',
  443. site: row.site,
  444. productGroupId: row.productGroupId,
  445. productGroupName: row.productGroupName,
  446. active: row.active,
  447. type: row.type,
  448. updateBy: this.$store.state.user.name,
  449. }
  450. this.modalDisableFlag = true
  451. this.modalFlag = true
  452. },
  453. // ======== 新增/编辑/删除方法 ========
  454. /**
  455. * 商品信息新增/编辑
  456. */
  457. saveData () {
  458. if (this.modalData.productGroupId === '' || this.modalData.productGroupId == null) {
  459. this.$message.warning('请填写商品组编码!')
  460. return
  461. }
  462. if (this.modalData.productGroupName === '' || this.modalData.productGroupName == null) {
  463. this.$message.warning('请填写商品组名称!')
  464. return
  465. }
  466. if (this.modalData.active === '' || this.modalData.active == null) {
  467. this.$message.warning('请选择是否可用!')
  468. return
  469. }
  470. if (this.modalData.type === '' || this.modalData.type == null) {
  471. this.$message.warning('请选择商品组!')
  472. return
  473. }
  474. if (this.modalData.flag === '1') {
  475. productGroupInformationSave(this.modalData).then(({data}) => {
  476. if (data && data.code === 0) {
  477. this.getDataList()
  478. this.modalFlag = false
  479. this.$message({
  480. message: '操作成功',
  481. type: 'success',
  482. duration: 1500,
  483. onClose: () => {}
  484. })
  485. } else {
  486. this.$alert(data.msg, '错误', {
  487. confirmButtonText: '确定'
  488. })
  489. }
  490. })
  491. } else {
  492. productGroupInformationEdit(this.modalData).then(({data}) => {
  493. if (data && data.code === 0) {
  494. this.getDataList()
  495. this.modalFlag = false
  496. this.$message({
  497. message: '操作成功',
  498. type: 'success',
  499. duration: 1500,
  500. onClose: () => {}
  501. })
  502. } else {
  503. this.$alert(data.msg, '错误', {
  504. confirmButtonText: '确定'
  505. })
  506. }
  507. })
  508. }
  509. },
  510. /**
  511. * 商品信息删除
  512. */
  513. delModal (row) {
  514. this.$confirm(`是否删除这条商品组信息?`, '提示', {
  515. confirmButtonText: '确定',
  516. cancelButtonText: '取消',
  517. type: 'warning'
  518. }).then(() => {
  519. productGroupInformationDelete(row).then(({data}) => {
  520. if (data && data.code === 0) {
  521. this.getDataList()
  522. this.partSelections = []
  523. this.$message({
  524. message: '操作成功',
  525. type: 'success',
  526. duration: 1500,
  527. onClose: () => {}
  528. })
  529. } else {
  530. this.$alert(data.msg, '错误', {
  531. confirmButtonText: '确定'
  532. })
  533. }
  534. })
  535. }).catch(() => {
  536. })
  537. },
  538. }
  539. }
  540. </script>
  541. <style scoped lang="scss">
  542. /deep/ .customer-tab .el-tabs__content {
  543. padding: 0px !important;
  544. height: 459px;
  545. }
  546. </style>