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.

1143 lines
37 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="'BU'">
  5. <el-select v-model="searchData.bu" placeholder="请选择" clearable style="width: 130px">
  6. <el-option
  7. v-for = "i in userBuList"
  8. :key = "i.buNo"
  9. :label = "i.buDesc"
  10. :value = "i.buNo">
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item :label="'物料编码'">
  15. <el-input v-model="searchData.partNo" clearable style="width: 120px"></el-input>
  16. </el-form-item>
  17. <el-form-item :label="'物料名称'">
  18. <el-input v-model="searchData.partDesc" clearable style="width: 120px"></el-input>
  19. </el-form-item>
  20. <el-form-item :label="' '">
  21. <el-button type="primary" @click="getDataList">查询</el-button>
  22. <el-button type="primary" icon="el-icon-upload" @click="partCostUpload">导入物料成本</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-table
  26. :height="height"
  27. :data="dataList"
  28. ref="mainTable"
  29. border
  30. style="width: 100%;">
  31. <el-table-column
  32. v-for="(item,index) in columnList" :key="index"
  33. :sortable="item.columnSortable"
  34. :prop="item.columnProp"
  35. :header-align="item.headerAlign"
  36. :show-overflow-tooltip="item.showOverflowTooltip"
  37. :align="item.align"
  38. :fixed="item.fixed==''?false:item.fixed"
  39. :min-width="item.columnWidth"
  40. :label="item.columnLabel">
  41. <template slot-scope="scope">
  42. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  43. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. fixed="right"
  48. header-align="center"
  49. align="center"
  50. width="100"
  51. label="操作">
  52. <template slot-scope="scope">
  53. <el-link v-if="!authUpdate" style="cursor: pointer" @click="updateModal(scope.row)">修改</el-link>
  54. <el-link style="cursor: pointer" @click="costHistorySearch(scope.row)">成本历史</el-link>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <!-- 分页栏 -->
  59. <el-pagination
  60. @size-change="sizeChangeHandle"
  61. @current-change="currentChangeHandle"
  62. :current-page="pageIndex"
  63. :page-sizes="[20, 50, 100, 200, 500]"
  64. :page-size="pageSize"
  65. :total="totalPage"
  66. layout="total, sizes, prev, pager, next, jumper">
  67. </el-pagination>
  68. <!-- 编辑模态框 -->
  69. <el-dialog title="物料成本信息 - 修改" @close="closeDialog" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="596px">
  70. <el-form :inline="true" label-position="top" :model="modalData" style="margin-top: -5px;">
  71. <el-form :inline="true" label-position="top" :model="modalData">
  72. <el-form-item label="物料编码" prop="partNo">
  73. <el-input v-model="modalData.partNo" disabled style="width: 128px"></el-input>
  74. </el-form-item>
  75. <el-form-item label="物料描述" prop="partDesc">
  76. <el-input v-model="modalData.partDesc" disabled style="width: 330px"></el-input>
  77. </el-form-item>
  78. <el-form-item label="BU">
  79. <el-input v-model="modalData.buDesc" disabled style="width: 80px"></el-input>
  80. </el-form-item>
  81. </el-form>
  82. <el-form :inline="true" label-position="top" :model="modalData" style="margin-top: -5px;">
  83. <el-form-item label="物料分类编码" prop="familyID">
  84. <el-input v-model="modalData.familyID" disabled style="width: 128px"></el-input>
  85. </el-form-item>
  86. <el-form-item label="物料分类描述" prop="familyName">
  87. <el-input v-model="modalData.familyName" disabled style="width: 330px"></el-input>
  88. </el-form-item>
  89. <el-form-item label="计量单位">
  90. <el-input v-model="modalData.umId2" disabled style="width: 80px"></el-input>
  91. </el-form-item>
  92. </el-form>
  93. <el-form :inline="true" label-position="top" :model="modalData" style="margin-top: -5px;">
  94. <el-form-item label="商品组1编码" prop="otherGroup1">
  95. <el-input v-model="modalData.otherGroup1" disabled style="width: 128px"></el-input>
  96. </el-form-item>
  97. <el-form-item label="商品组1描述" prop="otherGroupName1">
  98. <el-input v-model="modalData.otherGroupName1" disabled style="width: 330px"></el-input>
  99. </el-form-item>
  100. </el-form>
  101. <el-form :inline="true" label-position="top" :model="modalData" style="margin-top: -5px;">
  102. <el-form-item label="单位标准成本" prop="standardCost">
  103. <el-input v-model="modalData.standardCost" @change="standardCostChange()" placeholder="最多6位小数" class="inlineNumber numInput" style="width: 107px"></el-input>
  104. </el-form-item>
  105. <el-form-item label="标准成本货币" prop="standardCostCurrency" :show-message="false">
  106. <span slot="label">
  107. <a @click="getBaseList(512)">标准成本货币</a>
  108. </span>
  109. <el-input v-model="modalData.standardCostCurrency" disabled @change="standardCostCurrencyChange()" style="width: 108px"></el-input>
  110. </el-form-item>
  111. <el-form-item label="单位报价成本" prop="actualCost">
  112. <el-input v-model="modalData.actualCost" placeholder="最多6位小数" class="inlineNumber numInput" style="width: 107px"></el-input>
  113. </el-form-item>
  114. <el-form-item label="报价成本货币" prop="actualCostCurrency" :show-message="false">
  115. <span slot="label">
  116. <a @click="getBaseList(513)">报价成本货币</a>
  117. </span>
  118. <el-input v-model="modalData.actualCostCurrency" disabled style="width: 108px"></el-input>
  119. </el-form-item>
  120. </el-form>
  121. <el-form :inline="true" label-position="top" :model="modalData" style="margin-top: 0px;">
  122. <el-form-item label="备注" style="height: 80px">
  123. <el-input v-model="modalData.costRemark" style="width: 565px"></el-input>
  124. </el-form-item>
  125. </el-form>
  126. </el-form>
  127. <el-footer style="height:35px;margin-top: -25px;text-align:center">
  128. <el-button type="primary" @click="saveData">保存</el-button>
  129. <el-button type="primary" @click="closeDialog">关闭</el-button>
  130. </el-footer>
  131. </el-dialog>
  132. <!-- 成本历史模态框 -->
  133. <el-dialog title="物料成本信息 - 成本历史" @close="closeCostHistoryDialog" :close-on-click-modal="false" v-drag :visible.sync="costHistoryFlag" width="680px">
  134. <el-table
  135. :height="height - 300"
  136. :data="costHistoryList"
  137. border
  138. style="width: 100%;">
  139. <el-table-column
  140. v-for="(item,index) in columnCostHistoryList" :key="index"
  141. :sortable="item.columnSortable"
  142. :prop="item.columnProp"
  143. :header-align="item.headerAlign"
  144. :show-overflow-tooltip="item.showOverflowTooltip"
  145. :align="item.align"
  146. :fixed="item.fixed==''?false:item.fixed"
  147. :min-width="item.columnWidth"
  148. :label="item.columnLabel">
  149. <template slot-scope="scope">
  150. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  151. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <span slot="footer" class="dialog-footer">
  156. <el-button type="primary" @click="closeCostHistoryDialog">关闭</el-button>
  157. </span>
  158. </el-dialog>
  159. <el-dialog :title="titleCon" @close="closeUploadDialog" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog">
  160. <el-form :inline="true" label-position="top" label-width="80px">
  161. <el-button type="primary" @click="downloadFile()">下载文件模板</el-button>
  162. <el-row>
  163. <el-col :span="24">
  164. <el-upload class="customer-upload" drag action="javascript:void(0);" ref="uploadFile" :limit="1" accept=".xlsx,.xls"
  165. :before-upload="beforeUploadHandle" :on-change="onChange" :auto-upload="false" style="text-align: left;">
  166. <i class="el-icon-upload"></i>
  167. <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
  168. </el-upload>
  169. </el-col>
  170. </el-row>
  171. </el-form>
  172. <span slot="footer" class="dialog-footer">
  173. <el-button type="primary" @click="saveUploadFile">保存</el-button>
  174. <el-button type="primary" @click="closeUploadDialog">关闭</el-button>
  175. </span>
  176. </el-dialog>
  177. <choose-list-eam ref="baseList" @getBaseData="getBaseData"></choose-list-eam>
  178. </div>
  179. </template>
  180. <script>
  181. import {partInformationSearch,partCostInformationEdit,savePartCostComponentByExcel} from "@/api/part/partInformation";
  182. import Chooselist from "../common/Chooselist.vue";
  183. import {getSiteAndBuByUserName, queryFileId} from "../../../api/qc/qc";
  184. import ChooseListEam from "../common/Chooselist_eam.vue";
  185. import {costHistorySearch, verifyData} from "../../../api/part/partInformation";
  186. import {getTableDefaultListLanguage, getTableUserListLanguage} from "../../../api/table";
  187. import {downLoadObjectFile} from "../../../api/eam/eam_object_list";
  188. export default {
  189. components: {
  190. ChooseListEam,
  191. Chooselist
  192. },
  193. data() {
  194. return {
  195. // ======== 行高 ========
  196. height: 200,
  197. // ======== 分页 ========
  198. pageIndex: 1,
  199. pageSize: 50,
  200. totalPage: 0,
  201. userBuList: [],
  202. // 导入
  203. titleCon: '文件导入',
  204. visible: false,
  205. fileList: [],
  206. // 条件查询
  207. searchData: {
  208. site: '',
  209. userName: this.$store.state.user.name,
  210. bu: '',
  211. buNo: '',
  212. partNo: '',
  213. partDesc: '',
  214. page: 1,
  215. limit: 10
  216. },
  217. modalData: {
  218. id: null,
  219. partId: null,
  220. bu: '',
  221. site: '',
  222. buNo: '',
  223. sourceBu: '',
  224. partNo: '',
  225. partDesc: '',
  226. umId2: '',
  227. umName: '',
  228. familyId: '',
  229. familyName: '',
  230. otherGroup1: '',
  231. otherGroupName1: '',
  232. standardCost: '',
  233. standardCostCurrency: '',
  234. actualCost: '',
  235. actualCostCurrency: '',
  236. costRemark: '',
  237. createBy: '',
  238. createDate: '',
  239. updateBy: '',
  240. updateDate: ''
  241. },
  242. originalData: {},
  243. // ======== 数据列表 ========
  244. dataList: [],
  245. costHistoryList: [],
  246. // 展示列集
  247. columnList: [
  248. {
  249. userId: this.$store.state.user.name,
  250. functionId: 6010011,
  251. serialNumber: '6010011Table1BuDesc',
  252. tableId: '6010011Table1',
  253. tableName: '物料成本表',
  254. columnProp: 'buDesc',
  255. headerAlign: 'center',
  256. align: 'center',
  257. columnLabel: 'BU',
  258. columnHidden: false,
  259. columnImage: false,
  260. columnSortable: false,
  261. sortLv: 0,
  262. status: true,
  263. fixed: '',
  264. columnWidth: 100
  265. },
  266. {
  267. userId: this.$store.state.user.name,
  268. functionId: 6010011,
  269. serialNumber: '6010011Table1PartNo',
  270. tableId: '6010011Table1',
  271. tableName: '物料成本表',
  272. columnProp: 'partNo',
  273. headerAlign: 'center',
  274. align: 'center',
  275. columnLabel: '物料编码',
  276. columnHidden: false,
  277. columnImage: false,
  278. columnSortable: false,
  279. sortLv: 0,
  280. status: true,
  281. fixed: '',
  282. columnWidth: 120
  283. },
  284. {
  285. userId: this.$store.state.user.name,
  286. functionId: 6010011,
  287. serialNumber: '6010011Table1PartDesc',
  288. tableId: '6010011Table1',
  289. tableName: '物料成本表',
  290. columnProp: 'partDesc',
  291. headerAlign: 'center',
  292. align: 'left',
  293. columnLabel: '物料描述',
  294. columnHidden: false,
  295. columnImage: false,
  296. columnSortable: false,
  297. sortLv: 0,
  298. status: true,
  299. fixed: '',
  300. columnWidth: 300
  301. },
  302. {
  303. userId: this.$store.state.user.name,
  304. functionId: 6010011,
  305. serialNumber: '6010011Table1UmId2',
  306. tableId: '6010011Table1',
  307. tableName: '物料成本表',
  308. columnProp: 'umId2',
  309. headerAlign: 'center',
  310. align: 'center',
  311. columnLabel: '计量单位编码',
  312. columnHidden: false,
  313. columnImage: false,
  314. columnSortable: false,
  315. sortLv: 0,
  316. status: true,
  317. fixed: '',
  318. columnWidth: 100
  319. },
  320. {
  321. userId: this.$store.state.user.name,
  322. functionId: 6010011,
  323. serialNumber: '6010011Table1UmName',
  324. tableId: '6010011Table1',
  325. tableName: '物料成本表',
  326. columnProp: 'umName',
  327. headerAlign: 'center',
  328. align: 'left',
  329. columnLabel: '计量单位名称',
  330. columnHidden: false,
  331. columnImage: false,
  332. columnSortable: false,
  333. sortLv: 0,
  334. status: true,
  335. fixed: '',
  336. columnWidth: 150
  337. },
  338. {
  339. userId: this.$store.state.user.name,
  340. functionId: 6010011,
  341. serialNumber: '6010011Table1PartType2Desc',
  342. tableId: '6010011Table1',
  343. tableName: '物料成本表',
  344. columnProp: 'partType2Desc',
  345. headerAlign: 'center',
  346. align: 'center',
  347. columnLabel: '零件类型',
  348. columnHidden: false,
  349. columnImage: false,
  350. columnSortable: false,
  351. sortLv: 0,
  352. status: true,
  353. fixed: '',
  354. columnWidth: 100
  355. },
  356. {
  357. userId: this.$store.state.user.name,
  358. functionId: 6010011,
  359. serialNumber: '6010011Table1FamilyId',
  360. tableId: '6010011Table1',
  361. tableName: '物料成本表',
  362. columnProp: 'familyId',
  363. headerAlign: 'center',
  364. align: 'center',
  365. columnLabel: '物料分类编码',
  366. columnHidden: false,
  367. columnImage: false,
  368. columnSortable: false,
  369. sortLv: 0,
  370. status: true,
  371. fixed: '',
  372. columnWidth: 120
  373. },
  374. {
  375. userId: this.$store.state.user.name,
  376. functionId: 6010011,
  377. serialNumber: '6010011Table1FamilyName',
  378. tableId: '6010011Table1',
  379. tableName: '物料成本表',
  380. columnProp: 'familyName',
  381. headerAlign: 'center',
  382. align: 'center',
  383. columnLabel: '物料分类描述',
  384. columnHidden: false,
  385. columnImage: false,
  386. columnSortable: false,
  387. sortLv: 0,
  388. status: true,
  389. fixed: '',
  390. columnWidth: 120
  391. },
  392. {
  393. userId: this.$store.state.user.name,
  394. functionId: 6010011,
  395. serialNumber: '6010011Table1ProductGroupId1',
  396. tableId: '6010011Table1',
  397. tableName: '物料成本表',
  398. columnProp: 'productGroupId1',
  399. headerAlign: 'center',
  400. align: 'center',
  401. columnLabel: '商品组1编码',
  402. columnHidden: false,
  403. columnImage: false,
  404. columnSortable: false,
  405. sortLv: 0,
  406. status: true,
  407. fixed: '',
  408. columnWidth: 100
  409. },
  410. {
  411. userId: this.$store.state.user.name,
  412. functionId: 6010011,
  413. serialNumber: '6010011Table1ProductGroupName1',
  414. tableId: '6010011Table1',
  415. tableName: '物料成本表',
  416. columnProp: 'productGroupName1',
  417. headerAlign: 'center',
  418. align: 'left',
  419. columnLabel: '商品组1名称',
  420. columnHidden: false,
  421. columnImage: false,
  422. columnSortable: false,
  423. sortLv: 0,
  424. status: true,
  425. fixed: '',
  426. columnWidth: 150
  427. },
  428. {
  429. userId: this.$store.state.user.name,
  430. functionId: 6010011,
  431. serialNumber: '6010011Table1StandardCost',
  432. tableId: '6010011Table1',
  433. tableName: '物料成本表',
  434. columnProp: 'standardCost',
  435. headerAlign: 'center',
  436. align: 'right',
  437. columnLabel: '单位标准成本',
  438. columnHidden: false,
  439. columnImage: false,
  440. columnSortable: false,
  441. sortLv: 0,
  442. status: true,
  443. fixed: '',
  444. columnWidth: 100
  445. },
  446. {
  447. userId: this.$store.state.user.name,
  448. functionId: 6010011,
  449. serialNumber: '6010011Table1StandardCostCurrency',
  450. tableId: '6010011Table1',
  451. tableName: '物料成本表',
  452. columnProp: 'standardCostCurrency',
  453. headerAlign: 'center',
  454. align: 'center',
  455. columnLabel: '标准成本货币',
  456. columnHidden: false,
  457. columnImage: false,
  458. columnSortable: false,
  459. sortLv: 0,
  460. status: true,
  461. fixed: '',
  462. columnWidth: 100
  463. },
  464. {
  465. userId: this.$store.state.user.name,
  466. functionId: 6010011,
  467. serialNumber: '6010011Table1ActualCost',
  468. tableId: '6010011Table1',
  469. tableName: '物料成本表',
  470. columnProp: 'actualCost',
  471. headerAlign: 'center',
  472. align: 'right',
  473. columnLabel: '单位报价成本',
  474. columnHidden: false,
  475. columnImage: false,
  476. columnSortable: false,
  477. sortLv: 0,
  478. status: true,
  479. fixed: '',
  480. columnWidth: 100
  481. },
  482. {
  483. userId: this.$store.state.user.name,
  484. functionId: 6010011,
  485. serialNumber: '6010011Table1ActualCostCurrency',
  486. tableId: '6010011Table1',
  487. tableName: '物料成本表',
  488. columnProp: 'actualCostCurrency',
  489. headerAlign: 'center',
  490. align: 'center',
  491. columnLabel: '报价成本货币',
  492. columnHidden: false,
  493. columnImage: false,
  494. columnSortable: false,
  495. sortLv: 0,
  496. status: true,
  497. fixed: '',
  498. columnWidth: 100
  499. },
  500. {
  501. userId: this.$store.state.user.name,
  502. functionId: 6010011,
  503. serialNumber: '6010011Table1CostRemark',
  504. tableId: '6010011Table1',
  505. tableName: '物料成本表',
  506. columnProp: 'costRemark',
  507. headerAlign: 'center',
  508. align: 'left',
  509. columnLabel: '备注',
  510. columnHidden: false,
  511. columnImage: false,
  512. columnSortable: false,
  513. sortLv: 0,
  514. status: true,
  515. fixed: '',
  516. columnWidth: 200
  517. },
  518. {
  519. userId: this.$store.state.user.name,
  520. functionId: 6010011,
  521. serialNumber: '6010011Table1CreateDate',
  522. tableId: '6010011Table1',
  523. tableName: '物料成本表',
  524. columnProp: 'createDate',
  525. headerAlign: 'center',
  526. align: 'center',
  527. columnLabel: '创建时间',
  528. columnHidden: false,
  529. columnImage: false,
  530. columnSortable: false,
  531. sortLv: 0,
  532. status: true,
  533. fixed: '',
  534. columnWidth: 160
  535. },
  536. {
  537. userId: this.$store.state.user.name,
  538. functionId: 6010011,
  539. serialNumber: '6010011Table1CreateBy',
  540. tableId: '6010011Table1',
  541. tableName: '物料成本表',
  542. columnProp: 'createBy',
  543. headerAlign: 'center',
  544. align: 'center',
  545. columnLabel: '创建人',
  546. columnHidden: false,
  547. columnImage: false,
  548. columnSortable: false,
  549. sortLv: 0,
  550. status: true,
  551. fixed: '',
  552. columnWidth: 80
  553. },
  554. {
  555. userId: this.$store.state.user.name,
  556. functionId: 6010011,
  557. serialNumber: '6010011Table1UpdateDate',
  558. tableId: '6010011Table1',
  559. tableName: '物料成本表',
  560. columnProp: 'updateDate',
  561. headerAlign: 'center',
  562. align: 'center',
  563. columnLabel: '更新时间',
  564. columnHidden: false,
  565. columnImage: false,
  566. columnSortable: false,
  567. sortLv: 0,
  568. status: true,
  569. fixed: '',
  570. columnWidth: 160
  571. },
  572. {
  573. userId: this.$store.state.user.name,
  574. functionId: 6010011,
  575. serialNumber: '6010011Table1UpdateBy',
  576. tableId: '6010011Table1',
  577. tableName: '物料成本表',
  578. columnProp: 'updateBy',
  579. headerAlign: 'center',
  580. align: 'center',
  581. columnLabel: '更新人',
  582. columnHidden: false,
  583. columnImage: false,
  584. columnSortable: false,
  585. sortLv: 0,
  586. status: true,
  587. fixed: '',
  588. columnWidth: 80
  589. }
  590. ],
  591. columnCostHistoryList: [
  592. {
  593. userId: this.$store.state.user.name,
  594. functionId: 6010011,
  595. serialNumber: '6010011Table2FieldCaption',
  596. tableId: '6010011Table2',
  597. tableName: '物料成本表',
  598. columnProp: 'fieldcaption',
  599. headerAlign: 'center',
  600. align: 'center',
  601. columnLabel: '名称',
  602. columnHidden: false,
  603. columnImage: false,
  604. columnSortable: false,
  605. sortLv: 0,
  606. status: true,
  607. fixed: '',
  608. columnWidth: 100
  609. },
  610. {
  611. userId: this.$store.state.user.name,
  612. functionId: 6010011,
  613. serialNumber: '6010011Table2FieldName',
  614. tableId: '6010011Table2',
  615. tableName: '物料成本表',
  616. columnProp: 'fieldname',
  617. headerAlign: 'center',
  618. align: 'center',
  619. columnLabel: '字段',
  620. columnHidden: false,
  621. columnImage: false,
  622. columnSortable: false,
  623. sortLv: 0,
  624. status: true,
  625. fixed: '',
  626. columnWidth: 100
  627. },
  628. {
  629. userId: this.$store.state.user.name,
  630. functionId: 6010011,
  631. serialNumber: '6010011Table2OldValue',
  632. tableId: '6010011Table2',
  633. tableName: '物料成本表',
  634. columnProp: 'oldvalue',
  635. headerAlign: 'center',
  636. align: 'center',
  637. columnLabel: 'Old Value',
  638. columnHidden: false,
  639. columnImage: false,
  640. columnSortable: false,
  641. sortLv: 0,
  642. status: true,
  643. fixed: '',
  644. columnWidth: 100
  645. },
  646. {
  647. userId: this.$store.state.user.name,
  648. functionId: 6010011,
  649. serialNumber: '6010011Table2NewValue',
  650. tableId: '6010011Table2',
  651. tableName: '物料成本表',
  652. columnProp: 'newvalue',
  653. headerAlign: 'center',
  654. align: 'center',
  655. columnLabel: 'New Value',
  656. columnHidden: false,
  657. columnImage: false,
  658. columnSortable: false,
  659. sortLv: 0,
  660. status: true,
  661. fixed: '',
  662. columnWidth: 100
  663. },
  664. {
  665. userId: this.$store.state.user.name,
  666. functionId: 6010011,
  667. serialNumber: '6010011Table2Recordtype',
  668. tableId: '6010011Table2',
  669. tableName: '物料成本表',
  670. columnProp: 'recordtype',
  671. headerAlign: 'center',
  672. align: 'center',
  673. columnLabel: '变更类型',
  674. columnHidden: false,
  675. columnImage: false,
  676. columnSortable: false,
  677. sortLv: 0,
  678. status: true,
  679. fixed: '',
  680. columnWidth: 100
  681. },
  682. {
  683. userId: this.$store.state.user.name,
  684. functionId: 6010011,
  685. serialNumber: '6010011Table2UserId',
  686. tableId: '6010011Table2',
  687. tableName: '物料成本表',
  688. columnProp: 'userid',
  689. headerAlign: 'center',
  690. align: 'center',
  691. columnLabel: '更新人',
  692. columnHidden: false,
  693. columnImage: false,
  694. columnSortable: false,
  695. sortLv: 0,
  696. status: true,
  697. fixed: '',
  698. columnWidth: 100
  699. },
  700. {
  701. userId: this.$store.state.user.name,
  702. functionId: 6010011,
  703. serialNumber: '6010011Table2CreateDate',
  704. tableId: '6010011Table2',
  705. tableName: '物料成本表',
  706. columnProp: 'createdate',
  707. headerAlign: 'center',
  708. align: 'center',
  709. columnLabel: '更新时间',
  710. columnHidden: false,
  711. columnImage: false,
  712. columnSortable: false,
  713. sortLv: 0,
  714. status: true,
  715. fixed: '',
  716. columnWidth: 100
  717. }
  718. ],
  719. // ======== 模态框开关控制 ========
  720. authSearch: false,
  721. authSave: false,
  722. authUpdate: false,
  723. authDelete: false,
  724. modalFlag: false,
  725. modalDisableFlag: false,
  726. costHistoryFlag: false,
  727. menuId: this.$route.meta.menuId,
  728. tagNo:undefined,
  729. }
  730. },
  731. mounted () {
  732. this.$nextTick(() => {
  733. this.height = window.innerHeight - 180
  734. })
  735. },
  736. created () {
  737. // 按钮控制
  738. this.getButtonAuthData()
  739. // 获取用户的 site 和 bu
  740. this.getSiteAndBuByUserName()
  741. // 动态列
  742. this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
  743. if (!this.authSearch) {
  744. // 获取数据列表
  745. this.getDataList()
  746. }
  747. },
  748. methods: {
  749. getBaseList(val){
  750. this.tagNo = val
  751. this.$nextTick(()=>{
  752. let strVal = ''
  753. let conSql = ''
  754. if (val === 512) {
  755. strVal = this.modalData.standardCostCurrency ? this.modalData.standardCostCurrency : ''
  756. }
  757. if (val === 513) {
  758. strVal = this.modalData.actualCostCurrency ? this.modalData.actualCostCurrency : ''
  759. }
  760. if (this.modalData.bu === null || this.modalData.bu === '') {
  761. this.$message.warning("请选择BU!")
  762. return
  763. } else {
  764. conSql = " and site = '" + this.modalData.bu.split('-')[0] + "'"
  765. }
  766. this.$refs.baseList.init(val, strVal, conSql)
  767. })
  768. },
  769. getBaseData(val){
  770. if (this.tagNo === 512){
  771. this.modalData.standardCostCurrency = val.Currency
  772. if (this.modalData.actualCostCurrency === '' || this.modalData.actualCostCurrency == null){
  773. this.modalData.actualCostCurrency = val.Currency
  774. }
  775. }
  776. if (this.tagNo === 513){
  777. this.modalData.actualCostCurrency = val.Currency
  778. }
  779. },
  780. // 获取用户的bu
  781. getSiteAndBuByUserName () {
  782. let tempData = {
  783. username: this.$store.state.user.name,
  784. }
  785. getSiteAndBuByUserName(tempData).then(({data}) => {
  786. if (data.code === 0) {
  787. this.userBuList = data.rows
  788. }
  789. })
  790. },
  791. // 每页数
  792. sizeChangeHandle (val) {
  793. this.pageSize = val
  794. this.pageIndex = 1
  795. this.getDataList()
  796. },
  797. // 当前页
  798. currentChangeHandle (val) {
  799. this.pageIndex = val
  800. this.getDataList()
  801. },
  802. //获取按钮的权限数据
  803. getButtonAuthData () {
  804. let searchFlag = this.isAuth(this.menuId+":search")
  805. let saveFlag = this.isAuth(this.menuId+":save")
  806. let updateFlag = this.isAuth(this.menuId+":update")
  807. let deleteFlag = this.isAuth(this.menuId+":delete")
  808. //处理页面的权限数据
  809. this.authSearch = !searchFlag
  810. this.authSave = !saveFlag
  811. this.authUpdate = !updateFlag
  812. this.authDelete = !deleteFlag
  813. },
  814. // ======== 列表数据刷新方法 ========
  815. /**
  816. * 获取数据列表
  817. */
  818. getDataList () {
  819. this.searchData.limit = this.pageSize
  820. this.searchData.page = this.pageIndex
  821. this.searchData.buNo = this.searchData.bu.split('_')[1]
  822. partInformationSearch(this.searchData).then(({data}) => {
  823. if (data.code === 0) {
  824. this.dataList = data.page.list
  825. this.pageIndex = data.page.currPage
  826. this.pageSize = data.page.pageSize
  827. this.totalPage = data.page.totalCount
  828. // 判断是否全部存在数据
  829. if (this.totalPage > 0) {
  830. // 设置选中行
  831. this.$refs.mainTable.setCurrentRow(this.dataList[0])
  832. }
  833. }
  834. })
  835. },
  836. updateModal (row) {
  837. this.modalData = {
  838. id: row.id,
  839. partId: row.partId,
  840. bu: row.site + '-' + row.sourceBu,
  841. site: row.site,
  842. buNo: row.sourceBu,
  843. buDesc: row.buDesc,
  844. partNo: row.partNo,
  845. partDesc: row.partDesc,
  846. umId2: row.umId2,
  847. umName: row.umName,
  848. familyId: row.familyId,
  849. familyName: row.familyName,
  850. otherGroup1: row.otherGroup1,
  851. otherGroupName1: row.otherGroupName1,
  852. standardCost: row.standardCost,
  853. standardCostCurrency: row.standardCostCurrency,
  854. actualCost: row.actualCost,
  855. actualCostCurrency: row.actualCostCurrency,
  856. costRemark: row.costRemark,
  857. createBy: row.createBy,
  858. createDate: row.createDate,
  859. }
  860. if (this.modalData.standardCost === null || this.modalData.standardCost === ''){
  861. this.modalData.standardCost = 0
  862. }
  863. if (this.modalData.standardCostCurrency === null || this.modalData.standardCostCurrency === ''){
  864. this.modalData.standardCostCurrency = 'CNY'
  865. }
  866. if (this.modalData.actualCost === null || this.modalData.actualCost === ''){
  867. this.modalData.actualCost = 0
  868. }
  869. if (this.modalData.actualCostCurrency === null || this.modalData.actualCostCurrency === ''){
  870. this.modalData.actualCostCurrency = 'CNY'
  871. }
  872. this.originalData = JSON.parse(JSON.stringify(this.modalData))
  873. this.modalFlag = true
  874. },
  875. saveData () {
  876. if (JSON.stringify(this.modalData) === JSON.stringify(this.originalData)) {
  877. this.closeDialog()
  878. return
  879. }
  880. // 单位标准成本 和单位报价成本只能为正整数的数字,提示2500ms
  881. let reg = /^[0-9]+.?[0-9]*/
  882. if (!reg.test(this.modalData.standardCost) || !reg.test(this.modalData.actualCost)) {
  883. this.$alert('单位标准成本和单位报价成本只能为正整数的数字!', '提示', {
  884. confirmButtonText: '确定',
  885. callback: action => {
  886. }
  887. })
  888. return
  889. }
  890. let inData = {
  891. id: this.modalData.id,
  892. partId: this.modalData.partId,
  893. bu: this.modalData.bu,
  894. site: this.modalData.site,
  895. buNo: this.modalData.buNo,
  896. standardCost: this.modalData.standardCost,
  897. standardCostCurrency: this.modalData.standardCostCurrency,
  898. actualCost: this.modalData.actualCost,
  899. actualCostCurrency: this.modalData.actualCostCurrency,
  900. costRemark: this.modalData.costRemark,
  901. updateBy: this.$store.state.user.name,
  902. updateDate:''
  903. }
  904. this.$confirm('确定保存吗?', '提示', {
  905. confirmButtonText: '确定',
  906. cancelButtonText: '取消',
  907. type: 'warning'
  908. }).then(() => {
  909. partCostInformationEdit(inData).then(({data}) => {
  910. if (data.code === 0) {
  911. this.$message({
  912. message: '保存成功',
  913. type: 'success'
  914. })
  915. this.getDataList()
  916. this.closeDialog()
  917. } else {
  918. this.$message.error(data.msg)
  919. }
  920. })
  921. }).catch(() => {
  922. this.$message({
  923. type: 'info',
  924. message: '已取消保存'
  925. })
  926. })
  927. },
  928. closeDialog () {
  929. this.modalData = {
  930. flag: '',
  931. title: '',
  932. bu: '',
  933. site: this.$store.state.user.site,
  934. buNo: '',
  935. partNo: '',
  936. partDesc: '',
  937. umId2: '',
  938. umName: '',
  939. familyId: '',
  940. familyName: '',
  941. otherGroup1: '',
  942. otherGroupName1: '',
  943. standardCost: '',
  944. standardCostCurrency: '',
  945. actualCost: '',
  946. actualCostCurrency: '',
  947. costRemark: '',
  948. }
  949. this.modalFlag = false
  950. },
  951. standardCostChange(){
  952. if (this.modalData.actualCost === '' || this.modalData.actualCost === null){
  953. this.modalData.actualCost = this.modalData.standardCost
  954. }
  955. },
  956. costHistorySearch(row) {
  957. let inData = {
  958. site: row.site,
  959. partno: row.partNo
  960. }
  961. costHistorySearch(inData).then(({data}) => {
  962. if (data.code === 0) {
  963. this.costHistoryList = data.rows
  964. this.costHistoryFlag = true
  965. } else {
  966. this.$message.error(data.msg)
  967. }
  968. })
  969. },
  970. closeCostHistoryDialog () {
  971. this.costHistoryFlag = false
  972. this.costHistoryList = []
  973. },
  974. // 动态列开始 获取 用户保存的 格式列
  975. async getTableUserColumn(tableId, columnId) {
  976. let queryTableUser = {
  977. userId: this.$store.state.user.name,
  978. functionId: this.$route.meta.menuId,
  979. tableId: tableId,
  980. status: true,
  981. languageCode: this.$i18n.locale
  982. }
  983. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  984. if (data.rows.length > 0) {
  985. switch (columnId) {
  986. case 1:
  987. this.columnList = data.rows
  988. break;
  989. }
  990. } else {
  991. this.getColumnList(tableId, columnId)
  992. }
  993. })
  994. },
  995. // 获取 tableDefault 列
  996. async getColumnList (tableId, columnId) {
  997. let queryTable= {
  998. functionId: this.$route.meta.menuId,
  999. tableId: tableId,
  1000. languageCode: this.$i18n.locale
  1001. }
  1002. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  1003. if (!data.rows.length === 0) {
  1004. switch (columnId) {
  1005. case 1:
  1006. this.columnList = data.rows
  1007. break;
  1008. }
  1009. }
  1010. })
  1011. },
  1012. partCostUpload () {
  1013. this.visible = true
  1014. },
  1015. // 关闭modal
  1016. closeUploadDialog () {
  1017. this.fileList = []
  1018. // 清空文件上传记录
  1019. this.$refs.uploadFile.clearFiles()
  1020. // 关闭当前的页面
  1021. this.visible = false
  1022. },
  1023. // 保修当前的数据
  1024. saveUploadFile () {
  1025. // 判断文件是否上传
  1026. if (null == this.fileList || 0 === this.fileList.length) {
  1027. this.$message.error("请先上传文件!")
  1028. return false
  1029. }
  1030. const formData = new FormData()
  1031. formData.append("file", this.fileList[0].raw)
  1032. formData.append("updateBy", this.$store.state.user.name)
  1033. formData.append("site", this.$store.state.user.site.toString())
  1034. savePartCostComponentByExcel(formData).then(({data}) => {
  1035. if (data.code === 0) {
  1036. this.$message.success(data.msg)
  1037. // 关闭窗口并刷新页面
  1038. this.closeUploadDialog()
  1039. } else {
  1040. this.$message.warning(data.msg)
  1041. }
  1042. })
  1043. },
  1044. // 上传之前
  1045. beforeUploadHandle (file) {
  1046. let extName = file[0].name.substring(file[0].name.lastIndexOf('.')).toLowerCase()
  1047. if (!(extName === '.xlsx' || extName === '.xls')) {
  1048. this.$message.error('数据导入失败,请选择正确的xlsx模板文件')
  1049. return false
  1050. }
  1051. },
  1052. // 选择上传文件时
  1053. onChange (file) {
  1054. this.fileList.push(file)
  1055. },
  1056. // 下载
  1057. async downloadFile () {
  1058. let file = {
  1059. id: 0,
  1060. fileName: ''
  1061. }
  1062. let tempData = {
  1063. orderRef1: 'partCost',
  1064. orderRef2: 'partCostFormat'
  1065. }
  1066. await queryFileId(tempData).then(({data}) => {
  1067. if (data && data.code === 0) {
  1068. file.id = data.data.id
  1069. file.fileName = data.data.fileName
  1070. } else {
  1071. this.$alert(data.msg, '错误', {
  1072. confirmButtonText: '确定'
  1073. })
  1074. }
  1075. })
  1076. await downLoadObjectFile(file).then(({data}) => {
  1077. // 不限制文件下载类型
  1078. const blob = new Blob([data], {type: "application/octet-stream"})
  1079. // 下载文件名称
  1080. const fileName = file.fileName
  1081. // a标签下载
  1082. const linkNode = document.createElement('a')
  1083. // a标签的download属性规定下载文件的名称
  1084. linkNode.download = fileName
  1085. linkNode.style.display = 'none'
  1086. // 生成一个Blob URL
  1087. linkNode.href = URL.createObjectURL(blob)
  1088. document.body.appendChild(linkNode)
  1089. // 模拟在按钮上的一次鼠标单击
  1090. linkNode.click()
  1091. // 释放URL 对象
  1092. URL.revokeObjectURL(linkNode.href)
  1093. document.body.removeChild(linkNode)
  1094. })
  1095. },
  1096. }
  1097. }
  1098. </script>
  1099. <style scoped>
  1100. .numInput /deep/ .el-input__inner{
  1101. text-align: right;
  1102. }
  1103. /deep/ .inlineNumber input::-webkit-outer-spin-button,
  1104. /deep/ .inlineNumber input::-webkit-inner-spin-button {
  1105. -webkit-appearance: none;
  1106. }
  1107. /deep/ .inlineNumber input[type="number"]{
  1108. -moz-appearance: textfield;
  1109. padding-right: 5px !important;
  1110. }
  1111. </style>
  1112. ```