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.

556 lines
17 KiB

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