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.

516 lines
15 KiB

2 years ago
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.manufacturerId" clearable style="width: 120px"></el-input>
  6. </el-form-item>
  7. <el-form-item :label="'制造商名称'">
  8. <el-input v-model="searchData.manufacturerName" 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="manufacturerId" :rules="rules.manufacturerId">
  81. <el-input v-model="modalData.manufacturerId" :disabled="modalDisableFlag" style="width: 140px"></el-input>
  82. </el-form-item>
  83. <el-form-item label="制造商名称" prop="manufacturerName" :rules="rules.manufacturerName">
  84. <el-input v-model="modalData.manufacturerName" 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 {
  106. manufacturerInformationSearch, // 制造商信息列表查询
  107. manufacturerInformationSave, // 制造商信息新增
  108. manufacturerInformationEdit, // 制造商信息编辑
  109. manufacturerInformationDelete // 制造商信息删除
  110. } from '@/api/part/manufacturerInformation.js'
  111. import Chooselist from '@/views/modules/common/Chooselist'
  112. import manufacturerInformation from './manufacturerInformation'
  113. export default {
  114. components: {
  115. Chooselist
  116. },
  117. watch: {
  118. searchData: {
  119. deep: true,
  120. handler: function (newV, oldV) {
  121. this.searchData.manufacturerId = this.searchData.manufacturerId.toUpperCase()
  122. }
  123. },
  124. modalData: {
  125. deep: true,
  126. handler: function (newV, oldV) {
  127. this.modalData.manufacturerId = this.modalData.manufacturerId.toUpperCase()
  128. }
  129. }
  130. },
  131. data () {
  132. return {
  133. // 导出
  134. exportData: [],
  135. exportName: '制造商' + this.dayjs().format('YYYYMMDDHHmmss'),
  136. exportHeader: ['制造商'],
  137. exportFooter: [],
  138. resultList: [],
  139. // ======== 行高 ========
  140. height: 200,
  141. // ======== 分页 ========
  142. pageIndex: 1,
  143. pageSize: 50,
  144. totalPage: 0,
  145. // 条件查询
  146. searchData: {
  147. site: this.$store.state.user.site,
  148. manufacturerId: '',
  149. manufacturerName: '',
  150. active: '',
  151. page: 1,
  152. limit: 10
  153. },
  154. // 其它
  155. dataListLoading: false,
  156. modalData: {
  157. flag: '',
  158. title: '',
  159. site: this.$store.state.user.site,
  160. manufacturerId: '',
  161. manufacturerName: '',
  162. active: ''
  163. },
  164. // ======== 数据列表 ========
  165. dataList: [],
  166. // 展示列集
  167. columnList: [
  168. {
  169. userId: this.$store.state.user.name,
  170. functionId: 104007,
  171. serialNumber: '104007Table1ManufacturerId',
  172. tableId: "104007Table1",
  173. tableName: "制造商信息表",
  174. columnProp: 'manufacturerId',
  175. headerAlign: "center",
  176. align: "center",
  177. columnLabel: '制造商编码',
  178. columnHidden: false,
  179. columnImage: false,
  180. columnSortable: false,
  181. sortLv: 0,
  182. status: true,
  183. fixed: '',
  184. columnWidth: 120
  185. },
  186. {
  187. userId: this.$store.state.user.name,
  188. functionId: 104007,
  189. serialNumber: '104007Table1ManufacturerName',
  190. tableId: "104007Table1",
  191. tableName: "制造商信息表",
  192. columnProp: 'manufacturerName',
  193. headerAlign: "center",
  194. align: "left",
  195. columnLabel: '制造商名称',
  196. columnHidden: false,
  197. columnImage: false,
  198. columnSortable: false,
  199. sortLv: 0,
  200. status: true,
  201. fixed: '',
  202. columnWidth: 300
  203. },
  204. {
  205. functionId: 104007,
  206. serialNumber: '104007Table1Active',
  207. tableId: '104007Table1',
  208. tableName: '制造商信息表',
  209. columnProp: 'active',
  210. headerAlign: 'center',
  211. align: 'center',
  212. columnLabel: '是否在用',
  213. columnHidden: false,
  214. columnImage: false,
  215. columnSortable: false,
  216. sortLv: 0,
  217. status: true,
  218. fixed: '',
  219. columnWidth: 100
  220. },
  221. {
  222. userId: this.$store.state.user.name,
  223. functionId: 104007,
  224. serialNumber: '104007Table1CreateDate',
  225. tableId: '104007Table1',
  226. tableName: '制造商信息表',
  227. columnProp: 'createDate',
  228. headerAlign: 'center',
  229. align: 'center',
  230. columnLabel: '创建时间',
  231. columnHidden: false,
  232. columnImage: false,
  233. columnSortable: false,
  234. sortLv: 0,
  235. status: true,
  236. fixed: '',
  237. columnWidth: 170
  238. },
  239. {
  240. userId: this.$store.state.user.name,
  241. functionId: 104007,
  242. serialNumber: '104007Table1CreateBy',
  243. tableId: "104007Table1",
  244. tableName: "制造商信息表",
  245. columnProp: 'createBy',
  246. headerAlign: "center",
  247. align: "center",
  248. columnLabel: '创建人',
  249. columnHidden: false,
  250. columnImage: false,
  251. columnSortable: false,
  252. sortLv: 0,
  253. status: true,
  254. fixed: '',
  255. columnWidth: 100
  256. },
  257. {
  258. userId: this.$store.state.user.name,
  259. functionId: 104007,
  260. serialNumber: '104007Table1UpdateDate',
  261. tableId: "104007Table1",
  262. tableName: "制造商信息表",
  263. columnProp: 'updateDate',
  264. headerAlign: "center",
  265. align: "center",
  266. columnLabel: '更新时间',
  267. columnHidden: false,
  268. columnImage: false,
  269. columnSortable: false,
  270. sortLv: 0,
  271. status: true,
  272. fixed: '',
  273. columnWidth: 170
  274. },
  275. {
  276. userId: this.$store.state.user.name,
  277. functionId: 104007,
  278. serialNumber: '104007Table1UpdateBy',
  279. tableId: "104007Table1",
  280. tableName: "制造商信息表",
  281. columnProp: 'updateBy',
  282. headerAlign: "center",
  283. align: "center",
  284. columnLabel: '更新人',
  285. columnHidden: false,
  286. columnImage: false,
  287. columnSortable: false,
  288. sortLv: 0,
  289. status: true,
  290. fixed: '',
  291. columnWidth: 100
  292. },
  293. ],
  294. rules:{
  295. manufacturerId:[
  296. {
  297. required: true,
  298. message: ' ',
  299. trigger: 'change'
  300. }
  301. ],
  302. manufacturerName:[
  303. {
  304. required: true,
  305. message: ' ',
  306. trigger: 'change'
  307. }
  308. ],
  309. active:[
  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 manufacturerInformationSearch(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. manufacturerInformationSearch(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. manufacturerId: '',
  390. manufacturerName: '',
  391. active: 'Y',
  392. }
  393. this.modalDisableFlag = false
  394. this.modalFlag = true
  395. },
  396. /**
  397. * 制造商信息编辑模态框
  398. * @param row
  399. */
  400. updateModal (row) {
  401. this.modalData = {
  402. flag: '2',
  403. title: '制造商编辑',
  404. site: row.site,
  405. manufacturerId: row.manufacturerId,
  406. manufacturerName: row.manufacturerName,
  407. active: row.active,
  408. updateBy: this.$store.state.user.name,
  409. }
  410. this.modalDisableFlag = true
  411. this.modalFlag = true
  412. },
  413. // ======== 新增/编辑/删除方法 ========
  414. /**
  415. * 制造商信息新增/编辑
  416. */
  417. saveData () {
  418. if (this.modalData.manufacturerId === '' || this.modalData.manufacturerId == null) {
  419. this.$message.warning('请填写制造商编码!')
  420. return
  421. }
  422. if (this.modalData.manufacturerName === '' || this.modalData.manufacturerName == null) {
  423. this.$message.warning('请填写制造商名称!')
  424. return
  425. }
  426. if (this.modalData.active === '' || this.modalData.active == null) {
  427. this.$message.warning('请选择是否可用!')
  428. return
  429. }
  430. if (this.modalData.flag === '1') {
  431. manufacturerInformationSave(this.modalData).then(({data}) => {
  432. if (data && data.code === 0) {
  433. this.getDataList()
  434. this.modalFlag = false
  435. this.$message({
  436. message: '操作成功',
  437. type: 'success',
  438. duration: 1500,
  439. onClose: () => {}
  440. })
  441. } else {
  442. this.$alert(data.msg, '错误', {
  443. confirmButtonText: '确定'
  444. })
  445. }
  446. })
  447. } else {
  448. manufacturerInformationEdit(this.modalData).then(({data}) => {
  449. if (data && data.code === 0) {
  450. this.getDataList()
  451. this.modalFlag = false
  452. this.$message({
  453. message: '操作成功',
  454. type: 'success',
  455. duration: 1500,
  456. onClose: () => {}
  457. })
  458. } else {
  459. this.$alert(data.msg, '错误', {
  460. confirmButtonText: '确定'
  461. })
  462. }
  463. })
  464. }
  465. },
  466. /**
  467. * 制造商信息删除
  468. */
  469. delModal (row) {
  470. this.$confirm(`是否删除这条制造商信息?`, '提示', {
  471. confirmButtonText: '确定',
  472. cancelButtonText: '取消',
  473. type: 'warning'
  474. }).then(() => {
  475. manufacturerInformationDelete(row).then(({data}) => {
  476. if (data && data.code === 0) {
  477. this.getDataList()
  478. this.partSelections = []
  479. this.$message({
  480. message: '操作成功',
  481. type: 'success',
  482. duration: 1500,
  483. onClose: () => {}
  484. })
  485. } else {
  486. this.$alert(data.msg, '错误', {
  487. confirmButtonText: '确定'
  488. })
  489. }
  490. })
  491. }).catch(() => {
  492. })
  493. },
  494. }
  495. }
  496. </script>
  497. <style scoped lang="scss">
  498. /deep/ .customer-tab .el-tabs__content {
  499. padding: 0px !important;
  500. height: 459px;
  501. }
  502. </style>