detail.vue 30 KB

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