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.

595 lines
18 KiB

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