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.

518 lines
15 KiB

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