detail.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. :loading="btnLoading"
  11. >返回列表</el-button>
  12. </div>
  13. <div class="add-customer-btn">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. class="el-button--small-yh"
  18. @click.stop="openEdit"
  19. v-if="disabled"
  20. >编 辑</el-button>
  21. <el-button
  22. v-if="checker && form.status != 3"
  23. type="primary"
  24. size="small"
  25. class="el-button--small-yh"
  26. @click.stop="openCheckDialog">
  27. 审批
  28. </el-button>
  29. <el-button
  30. v-if="form.status > 0"
  31. @click.native="checkScheduleDialog = true,checkId=form.id"
  32. type="primary"
  33. size="small"
  34. >审核进度</el-button>
  35. <el-button
  36. type="primary"
  37. v-if="!checkDisabled"
  38. :disabled="!form.id || disabled"
  39. size="small"
  40. @click="pleaseCheck"
  41. :loading="btnLoading"
  42. >请核</el-button>
  43. <el-button
  44. type="success"
  45. :disabled="!form.id"
  46. size="small"
  47. @click="copyDoc"
  48. :loading="btnLoading"
  49. v-if="false"
  50. >复制单据</el-button>
  51. <el-button
  52. type="primary"
  53. @click="editCustomer"
  54. size="small"
  55. :loading="btnLoading"
  56. :disabled="checkDisabled || disabled"
  57. >保存数据</el-button>
  58. </div>
  59. </div>
  60. <div class="customer-main">
  61. <containerTitle title="基础信息"/>
  62. <basic-container :showBtn="true">
  63. <avue-form
  64. ref="form"
  65. class="trading-form"
  66. v-model="form"
  67. :option="option"
  68. >
  69. <template slot="applyUser">
  70. <el-select
  71. v-model="form.applyUser"
  72. filterable
  73. clearable
  74. size="small"
  75. :disabled="checkDisabled || disabled"
  76. >
  77. <el-option
  78. v-for="(item,index) in userList"
  79. :key="index"
  80. :label="item.realName"
  81. :value="item.id"
  82. ></el-option>
  83. </el-select>
  84. </template>
  85. <template slot="applyDept">
  86. <avue-input-tree
  87. leaf-only
  88. style="width: 100%;"
  89. size="small"
  90. :props="{ label: 'title' }"
  91. v-model="form.applyDept"
  92. placeholder=" "
  93. type="tree"
  94. :dic="dic"
  95. :disabled="checkDisabled || disabled"
  96. ></avue-input-tree>
  97. </template>
  98. </avue-form>
  99. </basic-container>
  100. <containerTitle title="商品信息"/>
  101. <basic-container>
  102. <avue-crud
  103. ref="crud"
  104. :data="dataList"
  105. :option="tableOption"
  106. :cell-style="cellStyle"
  107. @saveColumn="saveColumn"
  108. @resetColumn="resetColumn"
  109. >
  110. <template slot="menuLeft">
  111. <el-button
  112. type="primary"
  113. icon="el-icon-plus"
  114. size="small"
  115. @click.stop="newDetails"
  116. :disabled="checkDisabled || disabled"
  117. >录入明细</el-button>
  118. <el-button
  119. type="info"
  120. icon="el-icon-printer"
  121. size="small"
  122. @click="openReport"
  123. >报表打印</el-button>
  124. </template>
  125. <template slot="menu" slot-scope="{ row, index }">
  126. <el-button
  127. size="small"
  128. icon="el-icon-edit"
  129. type="text"
  130. @click="rowCell(row, index)"
  131. :disabled="checkDisabled || disabled"
  132. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button>
  133. <el-button
  134. size="small"
  135. icon="el-icon-delete"
  136. type="text"
  137. @click="rowDel(row, index)"
  138. :disabled="checkDisabled || disabled"
  139. >删除</el-button>
  140. </template>
  141. <template slot="code" slot-scope="{ row, index }">
  142. <span v-if="row.$cellEdit" style="display:flex">
  143. <el-select
  144. v-model="row.code"
  145. placeholder="请选择"
  146. filterable
  147. size="small"
  148. style="width:60%"
  149. @change="codeChange(row, index)"
  150. >
  151. <el-option
  152. v-for="item in goodsoptions"
  153. :key="item.id"
  154. :label="item.code"
  155. :value="item.code"
  156. >
  157. </el-option>
  158. </el-select>
  159. <el-button
  160. icon="el-icon-search"
  161. size="small"
  162. @click="rePick(row, index)"
  163. ></el-button>
  164. </span>
  165. <span v-else> {{ row.code }}</span>
  166. </template>
  167. <template slot="cname" slot-scope="{ row, index }">
  168. <span v-if="row.$cellEdit" style="display:flex">
  169. <el-select
  170. v-model="row.itemId"
  171. placeholder="请选择"
  172. size="small"
  173. filterable
  174. style="width:60%"
  175. @change="cnameChange(row, index)"
  176. >
  177. <el-option
  178. v-for="item in goodsoptions"
  179. :key="item.id"
  180. :label="item.cname"
  181. :value="item.id"
  182. >
  183. </el-option>
  184. </el-select>
  185. <el-button
  186. icon="el-icon-search"
  187. size="small"
  188. @click="rePick(row, index)"
  189. ></el-button>
  190. </span>
  191. <span v-else> {{ row.cname }}</span>
  192. </template>
  193. <template slot="orderQuantity" slot-scope="{ row, index }">
  194. <el-input-number
  195. v-if="row.$cellEdit"
  196. v-model="row.orderQuantity"
  197. size="small"
  198. :controls="false"
  199. :precision="0"
  200. @input="amountChange(row)"
  201. style="width: 100%"
  202. />
  203. <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
  204. </template>
  205. <template slot="price" slot-scope="{ row, index }">
  206. <el-input-number
  207. v-if="row.$cellEdit"
  208. v-model="row.price"
  209. size="small"
  210. :controls="false"
  211. :precision="2"
  212. @input="amountChange(row)"
  213. style="width: 100%"
  214. ></el-input-number>
  215. <span v-else>{{ row.price }}</span>
  216. </template>
  217. <!-- 单位-->
  218. <template slot="unit" slot-scope="{ row, index }">
  219. <el-select
  220. v-if="row.$cellEdit"
  221. v-model="row.unit"
  222. size="small"
  223. clearable
  224. filterable
  225. >
  226. <el-option
  227. v-for="(item, index) in unitOption"
  228. :key="index"
  229. :label="item.dictValue"
  230. :value="item.dictValue"
  231. />
  232. </el-select>
  233. <span v-else>{{ row.unit }}</span>
  234. </template>
  235. <template slot="amount" slot-scope="{ row, index }">
  236. <span>{{ row.amount | decimalFormat }}</span>
  237. </template>
  238. <template slot="storageQuantity" slot-scope="{ row, index }">
  239. <span>{{ row.storageQuantity | IntegerFormat }}</span>
  240. </template>
  241. <template slot="remarks" slot-scope="{ row, index }">
  242. <el-input
  243. v-if="row.$cellEdit"
  244. v-model="row.remarks"
  245. size="small"
  246. />
  247. <span v-else>{{ row.remarks }}</span>
  248. </template>
  249. </avue-crud>
  250. </basic-container>
  251. </div>
  252. <!-- 商品弹窗-->
  253. <el-dialog
  254. title="导入商品"
  255. append-to-body
  256. class="el-dialogDeep"
  257. :visible.sync="dialogVisible"
  258. width="80%"
  259. :close-on-click-modal="false"
  260. :destroy-on-close="true"
  261. :close-on-press-escape="false"
  262. @close="closeGoods"
  263. top="5vh"
  264. v-dialog-drag
  265. >
  266. <span>
  267. <el-row>
  268. <el-col :span="4">
  269. <div>
  270. <el-scrollbar>
  271. <basic-container>
  272. <avue-tree
  273. :option="treeOption"
  274. @node-click="nodeClick"
  275. :style="treeStyle"
  276. />
  277. </basic-container>
  278. </el-scrollbar>
  279. </div>
  280. </el-col>
  281. <el-col :span="20">
  282. <avue-crud
  283. :option="goodsOption"
  284. :table-loading="loading"
  285. :data="goodsListShow"
  286. ref="goodsCrud"
  287. :search.sync="search"
  288. @search-change="searchChange"
  289. @selection-change="selectionChange"
  290. @row-click="rowClick"
  291. :page.sync="page"
  292. @on-load="onLoad"
  293. @saveColumn="saveGoodsColumn"
  294. @resetColumn="resetGoodsColumn"
  295. :cell-style="cellStyle"
  296. >
  297. <template slot="menuLeft">
  298. <el-tabs v-model="activeName" @tab-click="tabHandle">
  299. <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
  300. <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
  301. </el-tabs>
  302. </template>
  303. <template slot-scope="scope" slot="menu">
  304. <el-button
  305. type="text"
  306. icon="el-icon-edit"
  307. size="small"
  308. @click.stop="importStagList(scope.row,scope.index)"
  309. v-if="activeName=='searchList'"
  310. :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1"
  311. >选择
  312. </el-button>
  313. <el-button
  314. type="text"
  315. icon="el-icon-delete"
  316. size="small"
  317. @click.stop="removeStagList(scope.row,scope.index)"
  318. v-else
  319. >移除
  320. </el-button>
  321. </template>
  322. </avue-crud>
  323. </el-col>
  324. </el-row>
  325. </span>
  326. <span slot="footer" class="dialog-footer">
  327. <el-button @click="dialogVisible = false">取 消</el-button>
  328. <el-button
  329. type="primary"
  330. @click="importGoods"
  331. :disabled="selectionList.length == 0 && goodsListSave.length == 0"
  332. >导入</el-button
  333. >
  334. </span>
  335. </el-dialog>
  336. <el-dialog
  337. append-to-body
  338. title="审批"
  339. class="el-dialogDeep"
  340. :visible.sync="checkDialog"
  341. width="50%"
  342. :close-on-click-modal="false"
  343. :destroy-on-close="true"
  344. :close-on-press-escape="false"
  345. v-dialog-drag
  346. >
  347. <check
  348. :checkData="checkData"
  349. :checkDetail="false"
  350. :idList="[]"
  351. @choceCheckFun="choceCheckFun"
  352. >
  353. </check>
  354. </el-dialog>
  355. <el-dialog
  356. append-to-body
  357. title="审批进度"
  358. class="el-dialogDeep"
  359. :visible.sync="checkScheduleDialog"
  360. width="40%"
  361. :close-on-click-modal="false"
  362. :destroy-on-close="true"
  363. :close-on-press-escape="false"
  364. v-dialog-drag
  365. >
  366. <check-schedule
  367. :checkId="checkId"
  368. :batchNo="batchNo"
  369. @choceScheduleFun="choceScheduleFun"
  370. >
  371. </check-schedule>
  372. </el-dialog>
  373. <!-- 报表-->
  374. <report-dialog
  375. :switchDialog="switchDialog"
  376. :reportId="form.id"
  377. reportName="办公用品-采购"
  378. @onClose="onClose()"
  379. />
  380. </div>
  381. </template>
  382. <script>
  383. import tableOption from "./config/customerContact.json";
  384. import goodsOption from "./config/commodity.json";
  385. // import {getDeptLazyTree,
  386. // getGoods,} from "@/api/basicData/customerInquiry";
  387. import {getDeptLazyTree, getList as getGoods} from "@/api/basicData/commodityType";
  388. import {
  389. isDiscount,
  390. isPercentage,
  391. micrometerFormat,
  392. IntegerFormat
  393. } from "@/util/validate";
  394. import { gainUser } from "@/api/basicData/customerInquiry";
  395. import {getUserInfo} from "@/api/system/user";
  396. import {getDeptTree} from "@/api/system/dept";
  397. import { getCurrentDate } from "@/util/date";
  398. import {dataDetail, typeSave, removeGoods, pleaseCheck} from "@/api/officeSupplies/purchaseApply";
  399. import { contrastObj, contrastList } from "@/util/contrastData";
  400. import check from "@/components/check/check";
  401. import checkSchedule from "@/components/check/checkSchedule";
  402. import reportDialog from "@/components/report-dialog/main";
  403. export default {
  404. name: "detail",
  405. props: {
  406. detailData: {
  407. type: Object
  408. }
  409. },
  410. components: {
  411. check,
  412. checkSchedule,
  413. reportDialog
  414. },
  415. data() {
  416. return {
  417. disabled: false,
  418. pageLoading: false,
  419. btnLoading: false,
  420. form: {},
  421. option: {
  422. menuBtn: false,
  423. labelWidth: 100,
  424. column: [
  425. {
  426. label: "系统号",
  427. prop: "sysNo",
  428. span: 6,
  429. disabled: true
  430. },
  431. {
  432. label: "申请人",
  433. prop: "applyUser",
  434. rules: [
  435. {
  436. required: true,
  437. message: " ",
  438. trigger: "change"
  439. }
  440. ],
  441. span: 6,
  442. slot: true,
  443. },
  444. {
  445. label: "申请部门",
  446. prop: "applyDept",
  447. rules: [
  448. {
  449. required: true,
  450. message: " ",
  451. trigger: "change"
  452. }
  453. ],
  454. span: 6,
  455. slot: true,
  456. },
  457. {
  458. label: "申请时间",
  459. prop: "applyTime",
  460. span: 6,
  461. type: "date",
  462. format: "yyyy-MM-dd",
  463. valueFormat: "yyyy-MM-dd 00:00:00",
  464. rules: [
  465. {
  466. required: true,
  467. message: " ",
  468. trigger: "blur"
  469. }
  470. ]
  471. },
  472. {
  473. label: "备注",
  474. prop: "orderRemark",
  475. type: "textarea",
  476. minRows: 2,
  477. span: 24,
  478. },
  479. ],
  480. },
  481. dataList: [],
  482. tableOption: {},
  483. goodsoptions: [],
  484. unitOption: [],
  485. dialogVisible: false,
  486. selectionList: [],
  487. treeDeptId: null,
  488. reData: null,
  489. treeOption: {
  490. nodeKey: "id",
  491. lazy: true,
  492. treeLoad: function(node, resolve) {
  493. const parentId = node.level === 0 ? 0 : node.data.id;
  494. getDeptLazyTree(parentId).then(res => {
  495. resolve(
  496. res.data.data.map(item => {
  497. return {
  498. ...item,
  499. leaf: !item.hasChildren
  500. };
  501. })
  502. );
  503. });
  504. },
  505. addBtn: false,
  506. menu: false,
  507. size: "small",
  508. props: {
  509. label: "title",
  510. value: "value",
  511. children: "children"
  512. }
  513. },
  514. page: {
  515. pageSize: 10,
  516. currentPage: 1,
  517. total: 0
  518. },
  519. search: {},
  520. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  521. goodsOption: {},
  522. loading: false,
  523. goodData: [], // 存储所有商品信息
  524. switchDialog: false, // 报表弹窗控制
  525. userList: [],
  526. activeName: 'searchList',
  527. // 商品列表数据合计
  528. goodsListShow: [],
  529. // 商品列表暂存
  530. goodsListSave: [],
  531. pageList: {
  532. pageSize: 10,
  533. currentPage: 1,
  534. total: 0
  535. },
  536. dic: [],
  537. oldForm: {},
  538. oldDataList: [],
  539. checkDisabled: false, // 审核状态
  540. checker: false,
  541. checkId: '',
  542. batchNo:'',
  543. checkDialog: false,
  544. checkScheduleDialog: false,
  545. checkData: {},
  546. }
  547. },
  548. async created() {
  549. this.tableOption = await this.getColumnData(
  550. this.getColumnName(89),
  551. tableOption
  552. );
  553. this.goodsOption = await this.getColumnData(
  554. this.getColumnName(90),
  555. goodsOption
  556. );
  557. getGoods(1, 10).then(res => {
  558. if (res.data.data.total > 0) {
  559. this.goodsoptions = res.data.data.records;
  560. if (Math.ceil(res.data.data.total / 10) > 1) {
  561. for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  562. getGoods(i, 10).then(e => {
  563. this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  564. });
  565. }
  566. }
  567. }
  568. });
  569. gainUser().then(res => {
  570. this.userList = res.data.data;
  571. });
  572. getUserInfo().then(res => {
  573. this.$set(this.form, 'applyUser', res.data.data.id);
  574. this.$set(this.form, 'applyDept', res.data.data.deptId);
  575. })
  576. getDeptTree().then(res => {
  577. this.dic = res.data.data
  578. })
  579. this.getWorkDicts('unit').then(res => {
  580. this.unitOption = res.data.data;
  581. })
  582. this.$set(this.form, 'applyTime', getCurrentDate()); // 默认当前日期
  583. if (this.detailData.query) {
  584. this.disabled = true;
  585. this.option.column.map(e => {
  586. this.$set(e, 'disabled', true)
  587. })
  588. this.queryData(this.detailData.id);
  589. } else if (this.detailData.auditId) {
  590. this.checker = true;
  591. this.batchNo = this.detailData.check.batchNo
  592. this.queryData(this.detailData.id);
  593. }
  594. },
  595. filters: {
  596. IntegerFormat(num) {
  597. return IntegerFormat(num);
  598. },
  599. decimalFormat(num) {
  600. return num ? Number(num).toFixed(2) : "0.00";
  601. }
  602. },
  603. methods: {
  604. // 查询
  605. queryData(id) {
  606. this.pageLoading = true;
  607. dataDetail(id).then(res => {
  608. this.form = res.data.data;
  609. this.dataList = this.form.orderItemsList? this.form.orderItemsList: [];
  610. delete this.form.orderItemsList;
  611. this.oldForm = {...this.form};
  612. this.oldDataList = [...this.dataList];
  613. this.checkDisabled = this.form.status > 0? true: false;
  614. if (this.form.status > 0) {
  615. this.option.column.map(e => {
  616. this.$set(e, 'disabled', true)
  617. })
  618. }
  619. }).finally(() => {
  620. this.pageLoading = false;
  621. })
  622. },
  623. //返回列表
  624. backToList() {
  625. this.$emit("goBack");
  626. },
  627. // 编辑按钮触发
  628. openEdit() {
  629. this.disabled = false;
  630. this.option.column.map(e => {
  631. if (this.checkDisabled) {
  632. this.$set(e, 'disabled', true)
  633. } else {
  634. if (e.prop != 'sysNo') {
  635. this.$set(e, 'disabled', false)
  636. }
  637. }
  638. })
  639. },
  640. // 复制
  641. copyDoc() {
  642. this.$emit("copyOrder", this.form.id);
  643. },
  644. //修改提交触发
  645. editCustomer(status) {
  646. this.$refs["form"].validate((valid, done) => {
  647. done();
  648. if (valid) {
  649. this.btnLoading = true;
  650. this.form.billType = 'OCG';
  651. this.form.tradeType = 'OCG';
  652. this.$set(this.form, 'orderItemsList', this.dataList);
  653. typeSave(this.form).then(res => {
  654. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  655. this.queryData(res.data.data);
  656. }).finally(() => {
  657. this.btnLoading = false;
  658. })
  659. } else {
  660. return false
  661. }
  662. })
  663. },
  664. cellStyle() {
  665. return "padding:0;height:40px;";
  666. },
  667. async saveColumn() {
  668. const inSave = await this.saveColumnData(
  669. this.getColumnName(89),
  670. this.tableOption
  671. );
  672. if (inSave) {
  673. this.$message.success("保存成功");
  674. //关闭窗口
  675. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  676. this.$nextTick(() => {
  677. this.$refs.crud.doLayout()
  678. })
  679. }
  680. },
  681. async resetColumn() {
  682. this.tableOption = tableOption;
  683. const inSave = await this.delColumnData(
  684. this.getColumnName(89),
  685. tableOption
  686. );
  687. if (inSave) {
  688. this.$nextTick(() => {
  689. this.$refs.crud.doLayout()
  690. })
  691. this.$message.success("重置成功");
  692. //关闭窗口
  693. setTimeout(() => {
  694. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  695. }, 1000);
  696. }
  697. },
  698. //商品明细导入
  699. newDetails() {
  700. this.$refs["form"].validate((valid) => {
  701. if (valid) {
  702. this.dialogVisible = !this.dialogVisible;
  703. }
  704. })
  705. },
  706. rowCell(row, index) {
  707. if (row.$cellEdit == true) {
  708. this.$set(row, "$cellEdit", false);
  709. } else {
  710. this.$set(row, "$cellEdit", true);
  711. }
  712. },
  713. rowDel(row, index) {
  714. this.$confirm("确定删除数据?", {
  715. confirmButtonText: "确定",
  716. cancelButtonText: "取消",
  717. type: "warning"
  718. }).then(() => {
  719. if (row.id) {
  720. removeGoods(row.id).then(res => {
  721. this.$message({
  722. type: 'success',
  723. message: '删除成功!'
  724. })
  725. this.dataList.splice(row.$index, 1);
  726. })
  727. } else {
  728. this.$message({
  729. type: "success",
  730. message: "删除成功!"
  731. });
  732. this.dataList.splice(row.$index, 1);
  733. }
  734. });
  735. },
  736. codeChange(row) {
  737. this.goodsoptions.forEach(async e => {
  738. if (e.code == row.code) {
  739. row.itemId = e.id;
  740. row.cname = e.cname;
  741. row.code = e.code;
  742. row.corpId = e.corpId;
  743. row.corpName = e.corpName;
  744. row.unit = e.unit;
  745. row.priceCategory = e.goodsTypeName;
  746. row.price = e.price;
  747. }
  748. });
  749. },
  750. cnameChange(row) {
  751. let form = {};
  752. this.goodsoptions.forEach(async e => {
  753. if (e.id == row.itemId) {
  754. row.cname = e.cname;
  755. row.code = e.code;
  756. row.corpId = e.corpId;
  757. row.corpName = e.corpName;
  758. row.unit = e.unit;
  759. row.priceCategory = e.goodsTypeName;
  760. row.price = e.price;
  761. }
  762. });
  763. },
  764. rePick(row, index) {
  765. this.reData = {
  766. ...row,
  767. index: index
  768. };
  769. this.newDetails();
  770. },
  771. // 商品信息价格计算
  772. amountChange(row) {
  773. if (!row.orderQuantity) {
  774. row.orderQuantity = 0;
  775. }
  776. if (!row.price) {
  777. row.price = 0;
  778. }
  779. row.amount = Number(row.price) * Number(row.orderQuantity)
  780. },
  781. closeGoods() {
  782. this.selectionList = [];
  783. this.treeDeptId = "";
  784. this.reData = null;
  785. this.activeName = 'searchList';
  786. this.goodsListSave = [];
  787. },
  788. nodeClick(data) {
  789. this.treeDeptId = data.id;
  790. this.page.currentPage = 1;
  791. this.onLoad(this.page);
  792. },
  793. //商品查询
  794. onLoad(page, params = {}) {
  795. let obj = this.deepClone(Object.assign(params, this.search));
  796. this.loading = true;
  797. getGoods(page.currentPage, page.pageSize,obj, this.treeDeptId)
  798. .then(res => {
  799. const data = res.data.data;
  800. this.page.total = data.total;
  801. this.goodsList = data.records;
  802. this.pageList.total = data.total;
  803. this.goodsListShow = data.records;
  804. if (this.page.total) {
  805. this.goodsOption.height = window.innerHeight - 350;
  806. }
  807. })
  808. .finally(() => {
  809. this.loading = false;
  810. });
  811. },
  812. searchChange(params, done) {
  813. this.search = this.deepClone(params);
  814. this.onLoad(this.page, params);
  815. done();
  816. },
  817. selectionChange(list) {
  818. this.selectionList = list;
  819. },
  820. rowClick(row) {
  821. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  822. },
  823. async saveGoodsColumn() {
  824. const inSave = await this.saveColumnData(
  825. this.getColumnName(90),
  826. this.goodsOption
  827. );
  828. if (inSave) {
  829. this.$message.success("保存成功");
  830. //关闭窗口
  831. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  832. this.$nextTick(() => {
  833. this.$refs.goodsCrud.doLayout()
  834. })
  835. }
  836. },
  837. async resetGoodsColumn() {
  838. this.goodsOption = goodsOption;
  839. const inSave = await this.delColumnData(
  840. this.getColumnName(90),
  841. goodsOption
  842. );
  843. if (inSave) {
  844. this.$nextTick(() => {
  845. this.$refs.goodsCrud.doLayout()
  846. })
  847. this.$message.success("重置成功");
  848. //关闭窗口
  849. setTimeout(() => {
  850. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  851. }, 1000);
  852. }
  853. },
  854. // 标签页切换
  855. tabHandle(data) {
  856. if (data.name == 'searchList') {
  857. this.goodsListShow = this.goodsList;
  858. this.page.total = this.pageList.total
  859. } else if (data.name == 'importStaging') {
  860. this.goodsListShow = this.goodsListSave;
  861. this.page.total = 0
  862. }
  863. },
  864. removeStagList(row, index) {
  865. this.goodsListSave.splice(row.$index, 1)
  866. },
  867. importStagList(row, index) {
  868. this.goodsListSave.push(row);
  869. },
  870. importGoods() {
  871. if (this.reData) {
  872. if (this.selectionList.length != 1) {
  873. return this.$message.error("重新选择的时候只能选择一条数据");
  874. } else {
  875. this.selectionList.forEach(e => {
  876. this.dataList.forEach(async (item, index) => {
  877. if (index == this.reData.index) {
  878. item.itemId = e.id;
  879. item.code = e.code;
  880. item.cname = e.cname;
  881. item.corpId = e.corpId;
  882. item.corpName = e.corpName;
  883. item.unit = e.unit;
  884. item.priceCategory = e.goodsTypeName;
  885. item.price = e.price;
  886. item.$cellEdit = true;
  887. }
  888. });
  889. });
  890. }
  891. } else {
  892. if (this.goodsListSave.length > 0) { // 暂存的有数据
  893. this.goodsListSave.forEach(async e => {
  894. this.dataList.push({
  895. itemId: e.id,
  896. code: e.code,
  897. cname: e.cname,
  898. corpId: e.corpId,
  899. corpName: e.corpName,
  900. unit: e.unit,
  901. price: e.price,
  902. amount: 0,
  903. orderQuantity: 0,
  904. $cellEdit: true
  905. });
  906. });
  907. } else {
  908. this.selectionList.forEach(async e => {
  909. this.dataList.push({
  910. itemId: e.id,
  911. code: e.code,
  912. cname: e.cname,
  913. corpId: e.corpId,
  914. corpName: e.corpName,
  915. unit: e.unit,
  916. amount: 0,
  917. orderQuantity: 0,
  918. price: e.price,
  919. $cellEdit: true
  920. });
  921. });
  922. }
  923. }
  924. this.dialogVisible = false;
  925. },
  926. // 请核
  927. pleaseCheck() {
  928. if (this.verification()) {
  929. const data = {
  930. id : this.form.id,
  931. checkType: 'ocg',
  932. url: '/workManagement/purchaseApply/index',
  933. pageStatus:"this.$store.getters.officePurchaseStatus",
  934. pageLabel:"采购申请",
  935. checkFlag: 1,
  936. }
  937. this.btnLoading = true;
  938. pleaseCheck(data).then(res => {
  939. this.$message.success('请核成功')
  940. this.queryData(this.form.id)
  941. }).catch(() => {
  942. this.$message.error('请核失败')
  943. }).finally(() => {
  944. this.btnLoading = false;
  945. })
  946. }
  947. },
  948. // 验证新旧值对比
  949. verification() {
  950. if (contrastObj(this.form, this.oldForm) ||
  951. contrastList(this.dataList, this.oldDataList)) {
  952. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  953. confirmButtonText: "确定",
  954. cancelButtonText: "取消",
  955. type: "warning"
  956. }).then(() => {
  957. this.editCustomer();
  958. }).catch(() => {
  959. return false; //取消改动数据
  960. })
  961. } else {
  962. return true;
  963. }
  964. },
  965. //打开审核
  966. openCheckDialog(){
  967. this.checkData = this.detailData.check
  968. this.checkDialog = true;
  969. },
  970. //关闭审核
  971. choceCheckFun(){
  972. this.checkDialog = false;
  973. },
  974. choceScheduleFun(){
  975. this.checkScheduleDialog = false
  976. },
  977. // 报表
  978. openReport() {
  979. this.switchDialog =! this.switchDialog;
  980. },
  981. // 报表关闭
  982. onClose(val) {
  983. this.switchDialog = val;
  984. },
  985. },
  986. }
  987. </script>
  988. <style scoped>
  989. </style>