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.

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