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.

554 lines
17 KiB

  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. },
  143. data () {
  144. return {
  145. // 导出
  146. exportData: [],
  147. exportName: '商品组' + this.dayjs().format('YYYYMMDDHHmmss'),
  148. exportHeader: ['商品'],
  149. exportFooter: [],
  150. resultList: [],
  151. // ======== 行高 ========
  152. height: 200,
  153. // ======== 分页 ========
  154. pageIndex: 1,
  155. pageSize: 50,
  156. totalPage: 0,
  157. // 条件查询
  158. searchData: {
  159. site: this.$store.state.user.site,
  160. productGroupId: '',
  161. productGroupName: '',
  162. active: '',
  163. type: '',
  164. page: 1,
  165. limit: 10
  166. },
  167. // 其它
  168. dataListLoading: false,
  169. modalData: {
  170. flag: '',
  171. title: '',
  172. site: this.$store.state.user.site,
  173. productGroupId: '',
  174. productGroupName: '',
  175. active: '',
  176. type: ''
  177. },
  178. // ======== 数据列表 ========
  179. dataList: [],
  180. // 展示列集
  181. columnList: [
  182. {
  183. userId: this.$store.state.user.name,
  184. functionId: 100007,
  185. serialNumber: '100007Table1ProductGroupId',
  186. tableId: "100007Table1",
  187. tableName: "商品组信息表",
  188. columnProp: 'productGroupId',
  189. headerAlign: "center",
  190. align: "center",
  191. columnLabel: '商品组编码',
  192. columnHidden: false,
  193. columnImage: false,
  194. columnSortable: false,
  195. sortLv: 0,
  196. status: true,
  197. fixed: '',
  198. },
  199. {
  200. userId: this.$store.state.user.name,
  201. functionId: 100007,
  202. serialNumber: '100007Table1ProductGroupName',
  203. tableId: "100007Table1",
  204. tableName: "商品组信息表",
  205. columnProp: 'productGroupName',
  206. headerAlign: "center",
  207. align: "center",
  208. columnLabel: '商品组名称',
  209. columnHidden: false,
  210. columnImage: false,
  211. columnSortable: false,
  212. sortLv: 0,
  213. status: true,
  214. fixed: '',
  215. },
  216. {
  217. functionId: 100007,
  218. serialNumber: '100007Table1Active',
  219. tableId: '100007Table1',
  220. tableName: '商品组信息表',
  221. columnProp: 'active',
  222. headerAlign: 'center',
  223. align: 'center',
  224. columnLabel: '是否在用',
  225. columnHidden: false,
  226. columnImage: false,
  227. columnSortable: false,
  228. sortLv: 0,
  229. status: true,
  230. fixed: '',
  231. columnWidth: 120
  232. },
  233. {
  234. userId: this.$store.state.user.name,
  235. functionId: 100007,
  236. serialNumber: '100007Table1Type',
  237. tableId: "100007Table1",
  238. tableName: "商品组信息表",
  239. columnProp: 'type',
  240. headerAlign: "center",
  241. align: "center",
  242. columnLabel: '商品组',
  243. columnHidden: false,
  244. columnImage: false,
  245. columnSortable: false,
  246. sortLv: 0,
  247. status: true,
  248. fixed: '',
  249. },
  250. {
  251. userId: this.$store.state.user.name,
  252. functionId: 100007,
  253. serialNumber: '100007Table1CreateDate',
  254. tableId: '100007Table1',
  255. tableName: '商品组信息表',
  256. columnProp: 'createDate',
  257. headerAlign: 'center',
  258. align: 'center',
  259. columnLabel: '创建时间',
  260. columnHidden: false,
  261. columnImage: false,
  262. columnSortable: false,
  263. sortLv: 0,
  264. status: true,
  265. fixed: '',
  266. },
  267. {
  268. userId: this.$store.state.user.name,
  269. functionId: 100007,
  270. serialNumber: '100007Table1CreateBy',
  271. tableId: "100007Table1",
  272. tableName: "商品组信息表",
  273. columnProp: 'createBy',
  274. headerAlign: "center",
  275. align: "center",
  276. columnLabel: '创建人',
  277. columnHidden: false,
  278. columnImage: false,
  279. columnSortable: false,
  280. sortLv: 0,
  281. status: true,
  282. fixed: '',
  283. },
  284. {
  285. userId: this.$store.state.user.name,
  286. functionId: 100007,
  287. serialNumber: '100007Table1UpdateDate',
  288. tableId: "100007Table1",
  289. tableName: "商品组信息表",
  290. columnProp: 'updateDate',
  291. headerAlign: "center",
  292. align: "center",
  293. columnLabel: '更新时间',
  294. columnHidden: false,
  295. columnImage: false,
  296. columnSortable: false,
  297. sortLv: 0,
  298. status: true,
  299. fixed: '',
  300. },
  301. {
  302. userId: this.$store.state.user.name,
  303. functionId: 100007,
  304. serialNumber: '100007Table1UpdateBy',
  305. tableId: "100007Table1",
  306. tableName: "商品组信息表",
  307. columnProp: 'updateBy',
  308. headerAlign: "center",
  309. align: "center",
  310. columnLabel: '更新人',
  311. columnHidden: false,
  312. columnImage: false,
  313. columnSortable: false,
  314. sortLv: 0,
  315. status: true,
  316. fixed: '',
  317. },
  318. ],
  319. rules:{
  320. productGroupId:[
  321. {
  322. required: true,
  323. message: ' ',
  324. trigger: 'change'
  325. }
  326. ],
  327. productGroupName:[
  328. {
  329. required: true,
  330. message: ' ',
  331. trigger: 'change'
  332. }
  333. ],
  334. active:[
  335. {
  336. required: true,
  337. message: ' ',
  338. trigger: 'change'
  339. }
  340. ],
  341. type:[
  342. {
  343. required: true,
  344. message: ' ',
  345. trigger: 'change'
  346. }
  347. ],
  348. },
  349. // ======== 模态框开关控制 ========
  350. modalFlag: false,
  351. modalDisableFlag: false,
  352. }
  353. },
  354. mounted () {
  355. this.$nextTick(() => {
  356. this.height = window.innerHeight - 180
  357. })
  358. },
  359. created () {
  360. this.getDataList()
  361. },
  362. methods: {
  363. // 每页数
  364. sizeChangeHandle (val) {
  365. this.pageSize = val
  366. this.pageIndex = 1
  367. this.getDataList()
  368. },
  369. // 当前页
  370. currentChangeHandle (val) {
  371. this.pageIndex = val
  372. this.getDataList()
  373. },
  374. //导出excel
  375. async createExportData() {
  376. this.searchData.limit = -1
  377. this.searchData.page = 1
  378. await productGroupInformationSearch(this.searchData).then(({data}) => {
  379. this.exportList= data.page.list;
  380. })
  381. return this.exportList;
  382. },
  383. startDownload() {
  384. },
  385. finishDownload() {
  386. },
  387. fields() {
  388. let json = "{"
  389. this.columnList.forEach((item, index) => {
  390. if (index == this.columnList.length - 1) {
  391. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  392. } else {
  393. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  394. }
  395. })
  396. json += "}"
  397. let s = eval("(" + json + ")")
  398. return s
  399. },
  400. // 导出 end
  401. // 获取数据列表
  402. getDataList () {
  403. this.searchData.limit = this.pageSize
  404. this.searchData.page = this.pageIndex
  405. productGroupInformationSearch(this.searchData).then(({data}) => {
  406. if (data.code === 0) {
  407. this.dataList = data.page.list
  408. this.pageIndex = data.page.currPage
  409. this.pageSize = data.page.pageSize
  410. this.totalPage = data.page.totalCount
  411. }
  412. this.dataListLoading = false
  413. })
  414. },
  415. addModal(){
  416. this.modalData = {
  417. flag: '1',
  418. title: '商品组新增',
  419. site: this.$store.state.user.site,
  420. createBy: this.$store.state.user.name,
  421. productGroupId: '',
  422. productGroupName: '',
  423. active: 'Y',
  424. type: ''
  425. }
  426. this.modalDisableFlag = false
  427. this.modalFlag = true
  428. },
  429. /**
  430. * 商品信息编辑模态框
  431. * @param row
  432. */
  433. updateModal (row) {
  434. this.modalData = {
  435. flag: '2',
  436. title: '商品组编辑',
  437. site: row.site,
  438. productGroupId: row.productGroupId,
  439. productGroupName: row.productGroupName,
  440. active: row.active,
  441. type: row.type,
  442. updateBy: this.$store.state.user.name,
  443. }
  444. this.modalDisableFlag = true
  445. this.modalFlag = true
  446. },
  447. // ======== 新增/编辑/删除方法 ========
  448. /**
  449. * 商品信息新增/编辑
  450. */
  451. saveData () {
  452. if (this.modalData.productGroupId === '' || this.modalData.productGroupId == null) {
  453. this.$message.warning('请填写商品组编码!')
  454. return
  455. }
  456. if (this.modalData.productGroupName === '' || this.modalData.productGroupName == null) {
  457. this.$message.warning('请填写商品组名称!')
  458. return
  459. }
  460. if (this.modalData.active === '' || this.modalData.active == null) {
  461. this.$message.warning('请选择是否可用!')
  462. return
  463. }
  464. if (this.modalData.type === '' || this.modalData.type == null) {
  465. this.$message.warning('请选择商品组!')
  466. return
  467. }
  468. if (this.modalData.flag === '1') {
  469. productGroupInformationSave(this.modalData).then(({data}) => {
  470. if (data && data.code === 0) {
  471. this.getDataList()
  472. this.modalFlag = false
  473. this.$message({
  474. message: '操作成功',
  475. type: 'success',
  476. duration: 1500,
  477. onClose: () => {}
  478. })
  479. } else {
  480. this.$alert(data.msg, '错误', {
  481. confirmButtonText: '确定'
  482. })
  483. }
  484. })
  485. } else {
  486. productGroupInformationEdit(this.modalData).then(({data}) => {
  487. if (data && data.code === 0) {
  488. this.getDataList()
  489. this.modalFlag = false
  490. this.$message({
  491. message: '操作成功',
  492. type: 'success',
  493. duration: 1500,
  494. onClose: () => {}
  495. })
  496. } else {
  497. this.$alert(data.msg, '错误', {
  498. confirmButtonText: '确定'
  499. })
  500. }
  501. })
  502. }
  503. },
  504. /**
  505. * 商品信息删除
  506. */
  507. delModal (row) {
  508. this.$confirm(`是否删除这条商品组信息?`, '提示', {
  509. confirmButtonText: '确定',
  510. cancelButtonText: '取消',
  511. type: 'warning'
  512. }).then(() => {
  513. productGroupInformationDelete(row).then(({data}) => {
  514. if (data && data.code === 0) {
  515. this.getDataList()
  516. this.partSelections = []
  517. this.$message({
  518. message: '操作成功',
  519. type: 'success',
  520. duration: 1500,
  521. onClose: () => {}
  522. })
  523. } else {
  524. this.$alert(data.msg, '错误', {
  525. confirmButtonText: '确定'
  526. })
  527. }
  528. })
  529. }).catch(() => {
  530. })
  531. },
  532. }
  533. }
  534. </script>
  535. <style scoped lang="scss">
  536. /deep/ .customer-tab .el-tabs__content {
  537. padding: 0px !important;
  538. height: 459px;
  539. }
  540. </style>