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.

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