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.

488 lines
14 KiB

7 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="'ABC类编码'">
  5. <el-input v-model="searchData.abcClass" clearable style="width: 120px"></el-input>
  6. </el-form-item>
  7. <el-form-item :label="'ABC类名称'">
  8. <el-input v-model="searchData.abcClassDesc" clearable style="width: 210px"></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. <el-link style="cursor: pointer" @click="updateModal(scope.row)">修改</el-link>
  64. <el-link style="cursor: pointer" @click="delModal(scope.row)">删除</el-link>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <!-- 分页栏 -->
  69. <el-pagination style="margin-top: 0px"
  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="ABC类编码" prop="abcClass" :rules="rules.abcClass">
  81. <el-input v-model="modalData.abcClass" :disabled="modalDisableFlag" style="width: 140px"></el-input>
  82. </el-form-item>
  83. <el-form-item label="ABC类名称" prop="abcClassDesc" :rules="rules.abcClassDesc">
  84. <el-input v-model="modalData.abcClassDesc" style="width: 302px"></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: 140px">
  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 Chooselist from '@/views/modules/common/Chooselist'
  106. import {
  107. abcClassInformationDelete,
  108. abcClassInformationEdit,
  109. abcClassInformationSave,
  110. abcClassInformationSearch
  111. } from "../../../api/part/abcClassInformation";
  112. export default {
  113. components: {
  114. Chooselist
  115. },
  116. watch: {
  117. searchData: {
  118. deep: true,
  119. handler: function (newV, oldV) {
  120. this.searchData.abcClass = this.searchData.abcClass.toUpperCase()
  121. }
  122. },
  123. modalData: {
  124. deep: true,
  125. handler: function (newV, oldV) {
  126. this.modalData.abcClass = this.modalData.abcClass.toUpperCase()
  127. }
  128. }
  129. },
  130. data () {
  131. return {
  132. // 导出
  133. exportData: [],
  134. exportName: 'ABC类ABC类' + this.dayjs().format('YYYYMMDDHHmmss'),
  135. exportHeader: ['ABC类ABC类'],
  136. exportFooter: [],
  137. resultList: [],
  138. // ======== 行高 ========
  139. height: 200,
  140. // ======== 分页 ========
  141. pageIndex: 1,
  142. pageSize: 50,
  143. totalPage: 0,
  144. // 条件查询
  145. searchData: {
  146. site: this.$store.state.user.site,
  147. abcClass: '',
  148. abcClassDesc: '',
  149. active: '',
  150. page: 1,
  151. limit: 10
  152. },
  153. // 其它
  154. dataListLoading: false,
  155. modalData: {
  156. flag: '',
  157. title: '',
  158. site: this.$store.state.user.site,
  159. abcClass: '',
  160. abcClassDesc: '',
  161. active: ''
  162. },
  163. // ======== 数据列表 ========
  164. dataList: [],
  165. // 展示列集
  166. columnList: [
  167. {
  168. userId: this.$store.state.user.name,
  169. columnProp: 'abcClass',
  170. headerAlign: "center",
  171. align: "center",
  172. columnLabel: 'ABC类编码',
  173. columnHidden: false,
  174. columnImage: false,
  175. columnSortable: false,
  176. sortLv: 0,
  177. status: true,
  178. fixed: '',
  179. columnWidth: 120
  180. },
  181. {
  182. userId: this.$store.state.user.name,
  183. columnProp: 'abcClassDesc',
  184. headerAlign: "center",
  185. align: "left",
  186. columnLabel: 'ABC类名称',
  187. columnHidden: false,
  188. columnImage: false,
  189. columnSortable: false,
  190. sortLv: 0,
  191. status: true,
  192. fixed: '',
  193. columnWidth: 300
  194. },
  195. {
  196. userId: this.$store.state.user.name,
  197. columnProp: 'active',
  198. headerAlign: 'center',
  199. align: 'center',
  200. columnLabel: '是否在用',
  201. columnHidden: false,
  202. columnImage: false,
  203. columnSortable: false,
  204. sortLv: 0,
  205. status: true,
  206. fixed: '',
  207. columnWidth: 100
  208. },
  209. {
  210. userId: this.$store.state.user.name,
  211. columnProp: 'createDate',
  212. headerAlign: 'center',
  213. align: 'center',
  214. columnLabel: '创建时间',
  215. columnHidden: false,
  216. columnImage: false,
  217. columnSortable: false,
  218. sortLv: 0,
  219. status: true,
  220. fixed: '',
  221. columnWidth: 170
  222. },
  223. {
  224. userId: this.$store.state.user.name,
  225. columnProp: 'createBy',
  226. headerAlign: "center",
  227. align: "center",
  228. columnLabel: '创建人',
  229. columnHidden: false,
  230. columnImage: false,
  231. columnSortable: false,
  232. sortLv: 0,
  233. status: true,
  234. fixed: '',
  235. columnWidth: 100
  236. },
  237. {
  238. userId: this.$store.state.user.name,
  239. columnProp: 'updateDate',
  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. columnWidth: 170
  250. },
  251. {
  252. userId: this.$store.state.user.name,
  253. columnProp: 'updateBy',
  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. columnWidth: 100
  264. },
  265. ],
  266. rules:{
  267. abcClass:[
  268. {
  269. required: true,
  270. message: ' ',
  271. trigger: 'change'
  272. }
  273. ],
  274. abcClassDesc:[
  275. {
  276. required: true,
  277. message: ' ',
  278. trigger: 'change'
  279. }
  280. ],
  281. active:[
  282. {
  283. required: true,
  284. message: ' ',
  285. trigger: 'change'
  286. }
  287. ],
  288. },
  289. // ======== 模态框开关控制 ========
  290. modalFlag: false,
  291. modalDisableFlag: false,
  292. }
  293. },
  294. mounted () {
  295. this.$nextTick(() => {
  296. this.height = window.innerHeight - 170
  297. })
  298. },
  299. created () {
  300. this.getDataList()
  301. },
  302. methods: {
  303. // 每页数
  304. sizeChangeHandle (val) {
  305. this.pageSize = val
  306. this.pageIndex = 1
  307. this.getDataList()
  308. },
  309. // 当前页
  310. currentChangeHandle (val) {
  311. this.pageIndex = val
  312. this.getDataList()
  313. },
  314. //导出excel
  315. async createExportData() {
  316. this.searchData.limit = -1
  317. this.searchData.page = 1
  318. await abcClassInformationSearch(this.searchData).then(({data}) => {
  319. this.exportList= data.page.list;
  320. })
  321. return this.exportList;
  322. },
  323. startDownload() {
  324. },
  325. finishDownload() {
  326. },
  327. fields() {
  328. let json = "{"
  329. this.columnList.forEach((item, index) => {
  330. if (index == this.columnList.length - 1) {
  331. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  332. } else {
  333. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  334. }
  335. })
  336. json += "}"
  337. let s = eval("(" + json + ")")
  338. return s
  339. },
  340. // 导出 end
  341. // 获取数据列表
  342. getDataList () {
  343. this.searchData.limit = this.pageSize
  344. this.searchData.page = this.pageIndex
  345. abcClassInformationSearch(this.searchData).then(({data}) => {
  346. if (data.code === 0) {
  347. this.dataList = data.page.list
  348. this.pageIndex = data.page.currPage
  349. this.pageSize = data.page.pageSize
  350. this.totalPage = data.page.totalCount
  351. }
  352. this.dataListLoading = false
  353. })
  354. },
  355. addModal(){
  356. this.modalData = {
  357. flag: '1',
  358. title: 'ABC类新增',
  359. site: this.$store.state.user.site,
  360. createBy: this.$store.state.user.name,
  361. abcClass: '',
  362. abcClassDesc: '',
  363. active: 'Y',
  364. }
  365. this.modalDisableFlag = false
  366. this.modalFlag = true
  367. },
  368. /**
  369. * ABC类信息编辑模态框
  370. * @param row
  371. */
  372. updateModal (row) {
  373. this.modalData = {
  374. flag: '2',
  375. title: 'ABC类编辑',
  376. site: row.site,
  377. abcClass: row.abcClass,
  378. abcClassDesc: row.abcClassDesc,
  379. active: row.active,
  380. updateBy: this.$store.state.user.name,
  381. }
  382. this.modalDisableFlag = true
  383. this.modalFlag = true
  384. },
  385. // ======== 新增/编辑/删除方法 ========
  386. /**
  387. * ABC类信息新增/编辑
  388. */
  389. saveData () {
  390. if (this.modalData.abcClass === '' || this.modalData.abcClass == null) {
  391. this.$message.warning('请填写ABC类编码!')
  392. return
  393. }
  394. if (this.modalData.abcClassDesc === '' || this.modalData.abcClassDesc == null) {
  395. this.$message.warning('请填写ABC类名称!')
  396. return
  397. }
  398. if (this.modalData.active === '' || this.modalData.active == null) {
  399. this.$message.warning('请选择是否可用!')
  400. return
  401. }
  402. if (this.modalData.flag === '1') {
  403. abcClassInformationSave(this.modalData).then(({data}) => {
  404. if (data && data.code === 0) {
  405. this.getDataList()
  406. this.modalFlag = false
  407. this.$message({
  408. message: '操作成功',
  409. type: 'success',
  410. duration: 1500,
  411. onClose: () => {}
  412. })
  413. } else {
  414. this.$alert(data.msg, '错误', {
  415. confirmButtonText: '确定'
  416. })
  417. }
  418. })
  419. } else {
  420. abcClassInformationEdit(this.modalData).then(({data}) => {
  421. if (data && data.code === 0) {
  422. this.getDataList()
  423. this.modalFlag = false
  424. this.$message({
  425. message: '操作成功',
  426. type: 'success',
  427. duration: 1500,
  428. onClose: () => {}
  429. })
  430. } else {
  431. this.$alert(data.msg, '错误', {
  432. confirmButtonText: '确定'
  433. })
  434. }
  435. })
  436. }
  437. },
  438. /**
  439. * ABC类信息删除
  440. */
  441. delModal (row) {
  442. this.$confirm(`是否删除这条ABC类信息?`, '提示', {
  443. confirmButtonText: '确定',
  444. cancelButtonText: '取消',
  445. type: 'warning'
  446. }).then(() => {
  447. abcClassInformationDelete(row).then(({data}) => {
  448. if (data && data.code === 0) {
  449. this.getDataList()
  450. this.partSelections = []
  451. this.$message({
  452. message: '操作成功',
  453. type: 'success',
  454. duration: 1500,
  455. onClose: () => {}
  456. })
  457. } else {
  458. this.$alert(data.msg, '错误', {
  459. confirmButtonText: '确定'
  460. })
  461. }
  462. })
  463. }).catch(() => {
  464. })
  465. },
  466. }
  467. }
  468. </script>
  469. <style scoped lang="scss">
  470. /deep/ .customer-tab .el-tabs__content {
  471. padding: 0px !important;
  472. height: 459px;
  473. }
  474. </style>