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.

574 lines
18 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
1 year ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
3 years ago
1 year ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
  4. <el-form :inline="true" label-position="top" style="margin-top: 0px">
  5. <el-button type="primary" @click="addModal()">新增</el-button>
  6. <download-excel
  7. :fields="fields()"
  8. :data="exportData"
  9. type="xls"
  10. :name="exportName"
  11. :header="exportHeader"
  12. :footer="exportFooter"
  13. :fetch="createExportData"
  14. :before-generate="startDownload"
  15. :before-finish="finishDownload"
  16. worksheet="导出信息"
  17. class="el-button el-button--primary el-button--medium">
  18. {{ '导出' }}
  19. </download-excel>
  20. </el-form>
  21. </el-form>
  22. <el-table
  23. :data="dataList"
  24. height="240"
  25. border
  26. v-loading="dataListLoading"
  27. style="width: 100%; ">
  28. <el-table-column
  29. v-for="(item,index) in columnList1" :key="index"
  30. :sortable="item.columnSortable"
  31. :prop="item.columnProp"
  32. :header-align="item.headerAlign"
  33. :show-overflow-tooltip="item.showOverflowTooltip"
  34. :align="item.align"
  35. :fixed="item.fixed==''?false:item.fixed"
  36. :min-width="item.columnWidth"
  37. :label="item.columnLabel">
  38. <template slot-scope="scope">
  39. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  40. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  41. style="width: 100px; height: 80px"/></span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. header-align="center"
  46. align="center"
  47. width="150"
  48. fixed="right"
  49. label="操作">
  50. <template slot-scope="scope">
  51. <a type="text" size="small" @click="updateModel(scope.row)">修改</a>
  52. <a type="text" size="small" @click="deleteData(scope.row)">删除</a>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <el-pagination
  57. @size-change="sizeChangeHandle"
  58. @current-change="currentChangeHandle"
  59. :current-page="pageIndex"
  60. :page-sizes="[20, 50, 100, 1000]"
  61. :page-size="pageSize"
  62. :total="totalPage"
  63. layout="total, sizes, prev, pager, next, jumper">
  64. </el-pagination>
  65. <el-dialog
  66. width="600px"
  67. :title="!dataForm.id ? '添加' :'编辑'"
  68. :close-on-click-modal="false"
  69. :visible.sync="visible">
  70. <el-form :inline="true" label-position="top" label-width="100px" :rules="dataRole">
  71. <el-form-item :label="'物料编码'">
  72. <el-input v-model="dataForm.testPartNo" style="width: 130px" disabled></el-input>
  73. </el-form-item>
  74. <el-form-item prop="partTypeDesc" :rules="dataRole.partTypeDesc">
  75. <span slot="label" style="" @click="getBaseList(1013,1)"><a herf="#">物料类型</a></span>
  76. <el-input v-model="dataForm.partTypeDesc" style="width: 130px" readonly @focus="getBaseList(1013,1)" ></el-input>
  77. </el-form-item>
  78. </el-form>
  79. <el-form :inline="true" label-position="top" label-width="100px" :rules="dataRole">
  80. <el-form-item :label="'物料名称'" prop="partName" :rules="dataRole.partName">
  81. <el-input v-model="dataForm.partName" style="width: 562px" ></el-input>
  82. </el-form-item>
  83. </el-form>
  84. <el-form :inline="true" label-position="top" label-width="100px" >
  85. <el-form-item :label="'物料名称'">
  86. <el-input v-model="dataForm.partDesc" style="width: 562px" ></el-input>
  87. </el-form-item>
  88. </el-form>
  89. <el-form :inline="true" label-position="top" label-width="100px" >
  90. <el-form-item :label="'物料名称'">
  91. <el-input v-model="dataForm.partSpec" style="width: 562px" ></el-input>
  92. </el-form-item>
  93. </el-form>
  94. <el-form :inline="true" label-position="top" label-width="100px" >
  95. <el-form-item :label="'物料图号'">
  96. <el-input v-model="dataForm.materialNumber" style="width: 562px" ></el-input>
  97. </el-form-item>
  98. </el-form>
  99. <el-form :inline="true" label-position="top" label-width="100px" >
  100. <el-form-item :label="'备注'">
  101. <el-input v-model="dataForm.remark" style="width: 562px" ></el-input>
  102. </el-form-item>
  103. </el-form>
  104. <span slot="footer" class="dialog-footer">
  105. <el-button type="primary" @click="saveData()">{{'确定'}}</el-button>
  106. <el-button type="primary" @click="visible = false">{{'关闭'}}</el-button>
  107. </span>
  108. </el-dialog>
  109. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  110. </div>
  111. </template>
  112. <script>
  113. import {
  114. getProjectInfoPartList,
  115. saveProjectPart,
  116. deleteProjectPartWithId,
  117. } from "@/api/project/project.js"
  118. import Chooselist from '@/views/modules/common/Chooselist'
  119. export default {
  120. components: {
  121. Chooselist
  122. },
  123. data() {
  124. return {
  125. dataList: [],
  126. searchData: {
  127. page: 1,
  128. limit: 100,
  129. site:this.$store.state.user.site,
  130. username: this.$store.state.user.name,
  131. projectId: '',
  132. },
  133. exportList:[],
  134. pageIndex: 1,
  135. pageSize: 100,
  136. totalPage: 0,
  137. visible:false,
  138. dataListLoading: false,
  139. currentRow:'',
  140. columnList1:[
  141. {
  142. userId: this.$store.state.user.name,
  143. functionId: 101002003,
  144. serialNumber: '101002003Table4TestPartNo',
  145. tableId: "101002003Table4",
  146. tableName: "项目物料",
  147. columnProp: "testPartNo",
  148. headerAlign: "center",
  149. align: "left",
  150. columnLabel: "物料编码",
  151. columnHidden: false,
  152. columnImage: false,
  153. columnSortable: false,
  154. sortLv: 0,
  155. status: true,
  156. fixed: '',
  157. columnWidth: 80
  158. },{
  159. userId: this.$store.state.user.name,
  160. functionId: 101002003,
  161. serialNumber: '101002003Table4PartType',
  162. tableId: "101002003Table4",
  163. tableName: "项目物料",
  164. columnProp: "partType",
  165. headerAlign: "center",
  166. align: "left",
  167. columnLabel: "物料分类",
  168. columnHidden: false,
  169. columnImage: false,
  170. columnSortable: false,
  171. sortLv: 0,
  172. status: true,
  173. fixed: '',
  174. columnWidth: 60
  175. },{
  176. userId: this.$store.state.user.name,
  177. functionId: 101002003,
  178. serialNumber: '101002003Table4PartTypeDesc',
  179. tableId: "101002003Table4",
  180. tableName: "项目物料",
  181. columnProp: "partTypeDesc",
  182. headerAlign: "center",
  183. align: "left",
  184. columnLabel: "物料分类名称",
  185. columnHidden: false,
  186. columnImage: false,
  187. columnSortable: false,
  188. sortLv: 0,
  189. status: true,
  190. fixed: '',
  191. columnWidth: 80
  192. },{
  193. userId: this.$store.state.user.name,
  194. functionId: 101002003,
  195. serialNumber: '101002003Table4PartName',
  196. tableId: "101002003Table4",
  197. tableName: "项目物料",
  198. columnProp: "partName",
  199. headerAlign: "center",
  200. align: "left",
  201. columnLabel: "物料名称",
  202. columnHidden: false,
  203. columnImage: false,
  204. columnSortable: false,
  205. sortLv: 0,
  206. status: true,
  207. fixed: '',
  208. columnWidth: 160
  209. },{
  210. userId: this.$store.state.user.name,
  211. functionId: 101002003,
  212. serialNumber: '101002003Table4PartDesc',
  213. tableId: "101002003Table4",
  214. tableName: "项目物料",
  215. columnProp: "partDesc",
  216. headerAlign: "center",
  217. align: "left",
  218. columnLabel: "物料名称",
  219. columnHidden: false,
  220. columnImage: false,
  221. columnSortable: false,
  222. sortLv: 0,
  223. status: true,
  224. fixed: '',
  225. columnWidth: 160
  226. },{
  227. userId: this.$store.state.user.name,
  228. functionId: 101002003,
  229. serialNumber: '101002003Table4PartSpec',
  230. tableId: "101002003Table4",
  231. tableName: "项目物料",
  232. columnProp: "partSpec",
  233. headerAlign: "center",
  234. align: "left",
  235. columnLabel: "规格型号",
  236. columnHidden: false,
  237. columnImage: false,
  238. columnSortable: false,
  239. sortLv: 0,
  240. status: true,
  241. fixed: '',
  242. columnWidth: 120
  243. },{
  244. userId: this.$store.state.user.name,
  245. functionId: 101002003,
  246. serialNumber: '101002003Table4MaterialNumber',
  247. tableId: "101002003Table4",
  248. tableName: "项目物料",
  249. columnProp: "materialNumber",
  250. headerAlign: "center",
  251. align: "left",
  252. columnLabel: "物料图号",
  253. columnHidden: false,
  254. columnImage: false,
  255. columnSortable: false,
  256. sortLv: 0,
  257. status: true,
  258. fixed: '',
  259. columnWidth: 120
  260. },{
  261. userId: this.$store.state.user.name,
  262. functionId: 101002003,
  263. serialNumber: '101002003Table4Remark',
  264. tableId: "101002003Table4",
  265. tableName: "项目物料",
  266. columnProp: "remark",
  267. headerAlign: "center",
  268. align: "left",
  269. columnLabel: "备注",
  270. columnHidden: false,
  271. columnImage: false,
  272. columnSortable: false,
  273. sortLv: 0,
  274. status: true,
  275. fixed: '',
  276. columnWidth: 120
  277. },{
  278. userId: this.$store.state.user.name,
  279. functionId: 101002003,
  280. serialNumber: '101002003Table4CreateDate',
  281. tableId: "101002003Table4",
  282. tableName: "项目物料",
  283. columnProp: "createDate",
  284. headerAlign: "center",
  285. align: "left",
  286. columnLabel: "创建时间",
  287. columnHidden: false,
  288. columnImage: false,
  289. columnSortable: false,
  290. sortLv: 0,
  291. status: true,
  292. fixed: '',
  293. columnWidth: 160
  294. },{
  295. userId: this.$store.state.user.name,
  296. functionId: 101002003,
  297. serialNumber: '101002003Table4CreateBy',
  298. tableId: "101002003Table4",
  299. tableName: "项目物料",
  300. columnProp: "createBy",
  301. headerAlign: "center",
  302. align: "left",
  303. columnLabel: "创建人",
  304. columnHidden: false,
  305. columnImage: false,
  306. columnSortable: false,
  307. sortLv: 0,
  308. status: true,
  309. fixed: '',
  310. columnWidth: 80
  311. },{
  312. userId: this.$store.state.user.name,
  313. functionId: 101002003,
  314. serialNumber: '101002003Table4UpdateDate',
  315. tableId: "101002003Table4",
  316. tableName: "项目物料",
  317. columnProp: "updateDate",
  318. headerAlign: "center",
  319. align: "left",
  320. columnLabel: "上次修改日期",
  321. columnHidden: false,
  322. columnImage: false,
  323. columnSortable: false,
  324. sortLv: 0,
  325. status: true,
  326. fixed: '',
  327. columnWidth: 160
  328. },{
  329. userId: this.$store.state.user.name,
  330. functionId: 101002003,
  331. serialNumber: '101002003Table4UpdateBy',
  332. tableId: "101002003Table4",
  333. tableName: "项目物料",
  334. columnProp: "updateBy",
  335. headerAlign: "center",
  336. align: "left",
  337. columnLabel: "修改人",
  338. columnHidden: false,
  339. columnImage: false,
  340. columnSortable: false,
  341. sortLv: 0,
  342. status: true,
  343. fixed: '',
  344. columnWidth: 80
  345. },
  346. ],
  347. dataForm:{
  348. id:'',
  349. site: '',
  350. projectId: '',
  351. testPartNo:'',
  352. partType:'',
  353. partTypeDesc:'',
  354. partName:'',
  355. partDesc:'',
  356. partSpec:'',
  357. remark:'',
  358. materialNumber:'',
  359. username:'',
  360. },
  361. dataRole: {
  362. partTypeDesc: [
  363. {
  364. required: true,
  365. message: ' ',
  366. trigger: 'change'
  367. }
  368. ],
  369. partName: [
  370. {
  371. required: true,
  372. message: ' ',
  373. trigger: 'change'
  374. }
  375. ],
  376. },
  377. // 导出 start
  378. exportData: [],
  379. exportName: '项目物料'+this.dayjs().format('YYYYMMDDHHmmss'),
  380. exportHeader: ["项目物料"],
  381. exportFooter: [],
  382. // 导出 end
  383. }
  384. },
  385. methods: {
  386. // 获取基础数据列表S
  387. getBaseList (val, type) {
  388. this.tagNo = val
  389. this.tagNo1 = type
  390. this.$nextTick(() => {
  391. let strVal = ''
  392. if (val === 1013) {
  393. if(type==1) {
  394. strVal = this.dataForm.partType
  395. }
  396. }
  397. this.$refs.baseList.init(val, strVal)
  398. })
  399. },
  400. /* 列表方法的回调 */
  401. getBaseData (val) {
  402. if (this.tagNo === 1013) {
  403. if(this.tagNo1==1) {
  404. this.dataForm.partType = val.Base_id
  405. this.dataForm.partTypeDesc = val.Base_desc
  406. }
  407. }
  408. },
  409. //初始化组件的参数
  410. init(inData) {
  411. //初始化参数
  412. this.searchData = JSON.parse(JSON.stringify(inData));
  413. //刷新表格
  414. this.searchTable();
  415. },
  416. // 每页数
  417. sizeChangeHandle (val) {
  418. this.pageSize = val
  419. this.pageIndex = 1
  420. this.search()
  421. },
  422. // 当前页
  423. currentChangeHandle (val) {
  424. this.pageIndex = val
  425. this.search()
  426. },
  427. search(){
  428. this.searchData.limit = this.pageSize
  429. this.searchData.page = this.pageIndex
  430. // projectInfoSearch(this.searchData).then(({data}) => {
  431. // if (data.code == 0) {
  432. // this.dataList1 = data.page.list
  433. // this.pageIndex = data.page.currPage
  434. // this.pageSize = data.page.pageSize
  435. // this.totalPage = data.page.totalCount
  436. // if(this.dataList1.length>0){
  437. // this.$refs.mainTable.setCurrentRow(this.dataList1[0]);
  438. // this.changeData(this.dataList1[0])
  439. // }
  440. // }
  441. // this.dataListLoading = false
  442. // })
  443. },
  444. searchTable(){
  445. getProjectInfoPartList(this.searchData).then(({data}) => {
  446. //区分请求成功和失败的状况
  447. if (data && data.code == 0) {
  448. this.dataList = data.rows;
  449. } else {
  450. this.dataList = [];
  451. }
  452. });
  453. },
  454. addModal(){
  455. if(this.searchData.projectId==""||this.searchData.projectId==null){
  456. this.$alert('请选择项目!', '错误', {
  457. confirmButtonText: '确定'
  458. })
  459. return false;
  460. }
  461. this.dataForm={
  462. id:0,
  463. site: this.searchData.site,
  464. projectId: this.searchData.projectId,
  465. testPartNo:'',
  466. partType:'',
  467. partTypeDesc:'',
  468. partName:'',
  469. partDesc:'',
  470. partSpec:'',
  471. remark:'',
  472. materialNumber:'',
  473. username:this.$store.state.user.name,
  474. }
  475. this.visible=true;
  476. },
  477. updateModel(row){
  478. this.dataForm={
  479. id:row.id,
  480. site: row.site,
  481. projectId: row.projectId,
  482. testPartNo:row.testPartNo,
  483. partType:row.partType,
  484. partTypeDesc:row.partTypeDesc,
  485. partName:row.partName,
  486. partDesc:row.partDesc,
  487. partSpec:row.partSpec,
  488. remark:row.remark,
  489. materialNumber:row.materialNumber,
  490. username:this.$store.state.user.name,
  491. }
  492. this.visible=true;
  493. },
  494. saveData(){
  495. if(this.dataForm.partType==''||this.dataForm.partType==null){
  496. this.$alert('请选择物料类别!', '错误', {
  497. confirmButtonText: '确定'
  498. })
  499. return false;
  500. }
  501. if(this.dataForm.partName==''||this.dataForm.partName==null){
  502. this.$alert('请输入物料名称!', '错误', {
  503. confirmButtonText: '确定'
  504. })
  505. return false;
  506. }
  507. saveProjectPart(this.dataForm).then(({data}) => {
  508. if (data && data.code === 0) {
  509. this.$message.success( '操作成功')
  510. this.visible = false
  511. this.searchTable();
  512. } else {
  513. this.$message.error(data.msg)
  514. }
  515. })
  516. },
  517. deleteData(){
  518. this.$confirm('确定要删除这条数据?', '提示', {
  519. confirmButtonText: '确定',
  520. cancelButtonText: '取消',
  521. type: 'warning'
  522. }).then(() => {
  523. deleteProjectPartWithId(this.dataForm).then(({data}) => {
  524. if (data && data.code === 0) {
  525. this.$message.success( '操作成功')
  526. this.searchTable();
  527. } else {
  528. this.$message.error(data.msg)
  529. }
  530. })
  531. }).catch(() => {
  532. })
  533. },
  534. //导出excel
  535. //导出excel
  536. async createExportData() {
  537. this.searchData.limit = -1
  538. this.searchData.page = 1
  539. await projectInfoSearch(this.searchData).then(({data}) => {
  540. this.exportList= data.page.list;
  541. })
  542. return this.exportList;
  543. },
  544. startDownload() {
  545. // this.exportData = this.dataList
  546. },
  547. finishDownload() {
  548. },
  549. fields() {
  550. let json = "{"
  551. this.columnList1.forEach((item, index) => {
  552. if (index == this.columnList1.length - 1) {
  553. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  554. } else {
  555. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  556. }
  557. })
  558. json += "}"
  559. let s = eval("(" + json + ")")
  560. return s
  561. },
  562. },
  563. }
  564. </script>
  565. <style scoped>
  566. </style>