detailsPage.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="goBack()">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <el-button size="small" style="margin-right: 8px" :disabled="!form.id"
  11. @click="$refs.print.openDialog()">打印账单
  12. </el-button>
  13. <el-button size="small" style="margin-right: 8px" :disabled="!form.id"
  14. @click="$refs.report.openDialog()">报表设计
  15. </el-button>
  16. <el-button class="el-button--small-yh" style="margin-left: 6px;" type="primary" size="small"
  17. v-if="editButton" @click="inEdit">编 辑
  18. </el-button>
  19. <el-button v-if="!editButton" class="el-button--small-yh" style="margin-left: 6px;" type="primary"
  20. size="small" :disabled="form.status == '已开票'" @click="submit">保 存
  21. </el-button>
  22. <el-button v-if="form.id && form.status == '录入'" class="el-button--small-yh" style="margin-left: 6px;"
  23. type="success" size="small" @click="confirm">确认开票
  24. </el-button>
  25. <el-button v-if="form.id && form.status == '已开票'" class="el-button--small-yh" style="margin-left: 6px;"
  26. type="danger" size="small" @click="revoke">撤销开票
  27. </el-button>
  28. </div>
  29. </div>
  30. <div style="margin-top: 50px">
  31. <trade-card title="基础信息">
  32. <avue-form :option="optionForm" v-model="form" ref="form">
  33. <tempalte slot="corporateName" slot-scope="{ row }">
  34. <dic-select v-model="form.corporateName" placeholder="销售公司" key="id" label="cnName"
  35. res="records" url="/blade-los/bcorps/listByType" :filterable="true" :remote="true"
  36. dataName="cnName" @selectChange="dicChange('corporateName', $event)"
  37. :disabled="form.invoicingItemList.length > 0 || editButton || form.status == '已开票'"
  38. :searchShow="true" :treeShow="true"></dic-select>
  39. </tempalte>
  40. <tempalte slot="contractNumber" slot-scope="{ row }">
  41. <el-input v-model="form.contractNumber" placeholder="请输入 合同号"
  42. :disabled="form.invoicingItemList.length > 0 || editButton || form.status == '已开票'"
  43. size="small"></el-input>
  44. </tempalte>
  45. <tempalte slot="businessOrganizerName" slot-scope="{ row }">
  46. <dic-select v-model="form.businessOrganizerName" placeholder="销售公司" key="id" label="realName"
  47. res="records" url="/blade-user/page" :filterable="true" :remote="true" dataName="realName"
  48. :disabled="editButton || form.status == '已开票'">
  49. </dic-select>
  50. </tempalte>
  51. <!-- <tempalte slot="openingBank" slot-scope="{ row }">
  52. <dic-select ref="bank" v-model="form.openingBank" placeholder="开户行" key="id" label="accountBank"
  53. :filterable="true" :disabled="editDisabled"></dic-select>
  54. </tempalte>
  55. <tempalte slot="accountNumber" slot-scope="{ row }">
  56. <dic-select ref="bank2" v-model="form.accountNumber" placeholder="账号" key="id" label="accountNo"
  57. :filterable="true" :disabled="editDisabled"></dic-select>
  58. </tempalte>
  59. <tempalte slot="addressTel" slot-scope="{ row }">
  60. <dic-select ref="user" v-model="form.addressTel" placeholder="地址、电话" key="id" label="addr"
  61. :filterable="true" :disabled="editDisabled" :slotRight="true" rightLabel="tel" @selectChange="dicChange('addressTel', $event)"></dic-select>
  62. </tempalte> -->
  63. </avue-form>
  64. </trade-card>
  65. <trade-card title="基础明细">
  66. <avue-crud :option="option" :data="form.invoicingItemList" id="out-table" ref="crud"
  67. @selection-change="selectionChange" @resetColumn="resetColumn('crud', 'option', 'optionBack', 454)"
  68. @saveColumn="saveColumn('crud', 'option', 'optionBack', 454)">
  69. <template slot="menuLeft">
  70. <el-button type="primary" size="small" icon="el-icon-plus" @click="addRow"
  71. :disabled="form.invoicingItemList.length || editButton || form.status == '已开票'">导 入
  72. </el-button>
  73. </template>
  74. <tempalte slot="quantityForm" slot-scope="{ row }">
  75. <el-input-number v-if="row.$cellEdit" v-model="row.quantity" @change="countChange(row)"
  76. :controls="false" placeholder="请输入 数量" size="small" style="width: 100%;"></el-input-number>
  77. <span v-else>{{ row.quantity }}</span>
  78. </tempalte>
  79. <template slot="menu" slot-scope="{ row, index }">
  80. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)"
  81. :disabled="editButton || form.status == '已开票'">{{ row.$cellEdit ?
  82. "保存" : "编辑" }}</el-button>
  83. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row)"
  84. :disabled="editButton || form.status == '已开票'">删 除</el-button>
  85. </template>
  86. </avue-crud>
  87. </trade-card>
  88. <business-reports :id="form.id" ref="print" businessValue="MYDL_KPSQ" :type="true"></business-reports>
  89. <reports :id="form.id" ref="report" :assemblyForm="form" businessValue="MYDL_KPSQ"></reports>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import { submit, getDetail, confirmInvoicing, revokeInvoicing, getImport, itemRemove } from "@/api/iosBasicData/revenueInvoicing";
  95. import dicSelect from "@/components/dicSelect/main";
  96. import { getBcorpsDetail } from "@/api/iosBasicData/bcorps";
  97. import businessReports from "@/components/tradeAgency/businessReports.vue";
  98. import reports from "@/components/tradeAgency/reports.vue";
  99. import _ from "lodash";
  100. export default {
  101. name: "detailsPage",
  102. data() {
  103. return {
  104. editButton: false,
  105. userList: [],
  106. form: {
  107. billNoFormat: 'MYDL_KPSQ',
  108. businessTypeCode: 'MYDL_KPSQ',
  109. invoicingItemList: []
  110. },
  111. optionForm: {
  112. menuBtn: false,
  113. span: 8,
  114. disabled: false,
  115. column: [
  116. {
  117. label: "销售公司",
  118. prop: "corporateName",
  119. rules: [{
  120. required: true,
  121. message: " ",
  122. trigger: "blur"
  123. }],
  124. disabled: false
  125. },
  126. {
  127. label: "公司名称",
  128. prop: "buyCorporateName",
  129. rules: [{
  130. required: true,
  131. message: " ",
  132. trigger: "blur"
  133. }],
  134. disabled: false
  135. },
  136. {
  137. label: "合同号",
  138. prop: "contractNumber",
  139. rules: [{
  140. required: true,
  141. message: " ",
  142. trigger: "blur"
  143. }],
  144. disabled: false,
  145. },
  146. {
  147. label: "业务主办",
  148. prop: "businessOrganizerName",
  149. // type: 'select',
  150. // filterable: true,
  151. // remote: true,
  152. // dicUrl: "/api/blade-user/page?current=1&size=20&realName={{key}}",
  153. // props: {
  154. // label: 'realName',
  155. // value: 'realName',
  156. // res: 'data.records'
  157. // },
  158. disabled: false
  159. },
  160. {
  161. label: "开具发票号码",
  162. prop: "invoiceNo",
  163. disabled: false
  164. },
  165. {
  166. label: "纳税人识别号",
  167. prop: "taxpayerIdentification",
  168. disabled: false
  169. },
  170. {
  171. label: "开户行",
  172. prop: "openingBank",
  173. disabled: false
  174. },
  175. {
  176. label: "账号",
  177. prop: "accountNumber",
  178. disabled: false
  179. },
  180. {
  181. label: "地址、电话",
  182. prop: "addressTel",
  183. disabled: false
  184. },
  185. {
  186. label: "备注",
  187. prop: "remarks",
  188. disabled: false
  189. }
  190. ]
  191. },
  192. option: {},
  193. optionBack: {
  194. height: 'auto',
  195. calcHeight: 30,
  196. menuWidth: 140,
  197. border: true,
  198. index: true,
  199. addBtn: false,
  200. viewBtn: false,
  201. editBtn: false,
  202. delBtn: false,
  203. menu: true,
  204. refreshBtn: false,
  205. align: 'center',
  206. summaryText: "合计",
  207. showSummary: true,
  208. sumColumnList: [
  209. {
  210. name: "quantity",
  211. type: "sum",
  212. decimals: 0
  213. }, {
  214. name: "amount",
  215. type: "sum",
  216. decimals: 2
  217. }, {
  218. name: "thisAmount",
  219. type: "sum",
  220. decimals: 2
  221. }, {
  222. name: "invoicedAmount",
  223. type: "sum",
  224. decimals: 2
  225. }
  226. ],
  227. column: [
  228. {
  229. label: "货物名称",
  230. prop: "labelProductName",
  231. overHidden: true
  232. },
  233. {
  234. label: "规格",
  235. prop: "specifications",
  236. overHidden: true
  237. },
  238. {
  239. label: "数量",
  240. prop: "quantity",
  241. cell: true,
  242. slot: true,
  243. formslot: true,
  244. rules: [{
  245. required: true,
  246. message: " ",
  247. trigger: "blur"
  248. }],
  249. overHidden: true
  250. },
  251. {
  252. label: "计量单位",
  253. prop: "units",
  254. overHidden: true,
  255. cell: true,
  256. type: 'select',
  257. filterable: true,
  258. remote: true,
  259. dicUrl: "/api/blade-los/bunits/list?current=1&size=20&cnName={{key}}",
  260. props: {
  261. label: 'cnName',
  262. value: 'cnName',
  263. res: 'data.records'
  264. },
  265. },
  266. {
  267. label: "销售单价(含税)",
  268. prop: "price",
  269. overHidden: true
  270. },
  271. {
  272. label: "销售金额(含税)",
  273. prop: "amount",
  274. overHidden: true
  275. },
  276. {
  277. label: "本次发票金额",
  278. prop: "thisAmount",
  279. overHidden: true
  280. },
  281. {
  282. label: "已开发票金额",
  283. prop: "invoicedAmount",
  284. overHidden: true
  285. },
  286. {
  287. label: "备注",
  288. prop: "remarks",
  289. cell: true,
  290. overHidden: true
  291. }
  292. ]
  293. },
  294. }
  295. },
  296. components: {
  297. dicSelect,
  298. businessReports,
  299. reports
  300. },
  301. props: {
  302. detailData: Object
  303. },
  304. async created() {
  305. this.option = await this.getColumnData(this.getColumnName(454), this.optionBack);
  306. if (this.detailData.id) {
  307. this.editButton = true
  308. this.optionForm.disabled = true
  309. this.getDetails(this.detailData.id)
  310. }
  311. },
  312. methods: {
  313. inEdit() {
  314. this.editButton = false
  315. if (this.form.status == '录入') {
  316. this.optionForm.disabled = false
  317. }
  318. },
  319. addRow() {
  320. if (!this.form.corporateId) {
  321. return this.$message.error("请选择销售公司");
  322. }
  323. if (!this.form.contractNumber) {
  324. return this.$message.error("请输入合同号");
  325. }
  326. let obj = {
  327. corpId: this.form.corporateId,
  328. contractNo: this.form.contractNumber
  329. }
  330. getImport(obj).then(res => {
  331. res.data.data.forEach(item => {
  332. this.form.invoicingItemList.push({
  333. srcId: item.id,
  334. labelProductName: item.labelProductName,
  335. specifications: item.specifications,
  336. quantity: _.divide(_.subtract(item.amount, item.invoiceAmount), item.price),
  337. units: '千克',
  338. price: item.price,
  339. amount: item.amount,
  340. thisAmount: item.amount,
  341. invoicedAmount: item.invoiceAmount,
  342. $cellEdit: true,
  343. })
  344. })
  345. })
  346. },
  347. countChange(row) {
  348. row.thisAmount = _.multiply(Number(row.quantity ? row.quantity : 0), Number(row.price ? row.price : 0))
  349. if (row.thisAmount > Number(row.amount - row.invoicedAmount)) {
  350. row.quantity = 0
  351. row.thisAmount = 0
  352. return this.$message.error("本次金额不能大于金额减去已开票");
  353. }
  354. },
  355. // 编辑
  356. rowEdit(row) {
  357. if (row.$cellEdit == true) {
  358. if (!row.quantity) return this.$message.error("请输入数量");
  359. this.$set(row, '$cellEdit', false)
  360. } else {
  361. this.$set(row, '$cellEdit', true)
  362. }
  363. },
  364. dicChange(name, row) {
  365. if (name == 'corporateName') {
  366. if (row) {
  367. this.form.corporateId = row.id
  368. this.form.corporateName = row.cnName
  369. this.form.buyCorporateName = row.cnName
  370. this.form.openingBank = null
  371. this.form.accountNumber = null
  372. this.form.addressTel = null
  373. getBcorpsDetail(row.id).then(res => {
  374. // this.$refs.bank.getDicData(res.data.data.corpsBankList)
  375. // this.$refs.bank2.getDicData(res.data.data.corpsBankList)
  376. res.data.data.corpsBankList.forEach((item, index) => {
  377. if (index == 0) {
  378. this.form.openingBank = item.accountBank
  379. this.form.accountNumber = item.accountNo
  380. }
  381. })
  382. // this.$refs.user.getDicData(res.data.data.corpsAttnList)
  383. res.data.data.corpsAttnList.forEach((item, index) => {
  384. if (index == 0) {
  385. this.form.addressTel = item.addr + item.tel
  386. }
  387. })
  388. })
  389. } else {
  390. this.form.corporateId = null
  391. this.form.corporateName = null
  392. this.form.buyCorporateName = null
  393. this.form.openingBank = null
  394. this.form.accountNumber = null
  395. this.form.addressTel = null
  396. // this.$refs.bank.getDicData([])
  397. // this.$refs.bank2.getDicData([])
  398. // this.$refs.user.getDicData([])
  399. }
  400. }
  401. if (name == 'addressTel') {
  402. if (row) {
  403. this.form.addressTel = row.addr + row.tel
  404. } else {
  405. this.form.addressTel = null
  406. }
  407. }
  408. },
  409. rowDel(row, index) {
  410. this.$confirm("确定将选择数据删除?", {
  411. confirmButtonText: "确定",
  412. cancelButtonText: "取消",
  413. type: "warning"
  414. }).then(() => {
  415. if (row.id) {
  416. itemRemove({ ids: row.id }).then(res => {
  417. this.form.invoicingItemList.splice(index, 1);
  418. this.$message.success("操作成功!");
  419. });
  420. } else {
  421. this.form.invoicingItemList.splice(index, 1);
  422. this.$message.success("操作成功!");
  423. }
  424. }
  425. );
  426. },
  427. getDetails(id) {
  428. const loading = this.$loading({
  429. lock: true,
  430. text: '加载中',
  431. spinner: 'el-icon-loading',
  432. background: 'rgba(255,255,255,0.7)'
  433. });
  434. getDetail({ id: id }).then(res => {
  435. this.form = res.data.data
  436. this.$refs.crud.dicInit();
  437. }).finally(() => {
  438. loading.close()
  439. })
  440. },
  441. submit() {
  442. for (let row of this.form.invoicingItemList) {
  443. if (!row.quantity) {
  444. return this.$message.error("请输入数量");
  445. }
  446. }
  447. this.$refs["form"].validate((valid, done) => {
  448. done();
  449. if (valid) {
  450. const loading = this.$loading({
  451. lock: true,
  452. text: '加载中',
  453. spinner: 'el-icon-loading',
  454. background: 'rgba(255,255,255,0.7)'
  455. });
  456. submit(this.form).then(res => {
  457. this.$message.success("保存成功");
  458. this.getDetails(res.data.data.id)
  459. }).finally(() => {
  460. loading.close();
  461. })
  462. } else {
  463. return false;
  464. }
  465. });
  466. },
  467. confirm() {
  468. for (let row of this.form.invoicingItemList) {
  469. if (!row.quantity) {
  470. return this.$message.error("请输入数量");
  471. }
  472. }
  473. this.$refs["form"].validate((valid, done) => {
  474. done();
  475. if (valid) {
  476. this.$confirm("是否确认开票?", {
  477. confirmButtonText: "确定",
  478. cancelButtonText: "取消",
  479. type: "warning"
  480. }).then(() => {
  481. const loading = this.$loading({
  482. lock: true,
  483. text: '加载中',
  484. spinner: 'el-icon-loading',
  485. background: 'rgba(255,255,255,0.7)'
  486. });
  487. confirmInvoicing(this.form).then(res => {
  488. this.$message.success("操作成功");
  489. this.getDetails(res.data.data.id)
  490. this.editButton = true
  491. this.optionForm.disabled = true
  492. }).finally(() => {
  493. loading.close();
  494. })
  495. }
  496. );
  497. } else {
  498. return false;
  499. }
  500. });
  501. },
  502. revoke() {
  503. this.$confirm("是否撤销开票?", {
  504. confirmButtonText: "确定",
  505. cancelButtonText: "取消",
  506. type: "warning"
  507. }).then(() => {
  508. const loading = this.$loading({
  509. lock: true,
  510. text: '加载中',
  511. spinner: 'el-icon-loading',
  512. background: 'rgba(255,255,255,0.7)'
  513. });
  514. revokeInvoicing(this.form).then(res => {
  515. this.$message.success("操作成功");
  516. this.getDetails(res.data.data.id)
  517. this.editButton = true
  518. this.optionForm.disabled = true
  519. }).finally(() => {
  520. loading.close();
  521. })
  522. }
  523. );
  524. },
  525. //自定义列保存
  526. async saveColumn(ref, option, optionBack, code) {
  527. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  528. if (inSave) {
  529. this.$message.success("保存成功");
  530. //关闭窗口
  531. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  532. }
  533. },
  534. //自定义列重置
  535. async resetColumn(ref, option, optionBack, code) {
  536. this[option] = this[optionBack];
  537. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  538. if (inSave) {
  539. this.$message.success("重置成功");
  540. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  541. }
  542. },
  543. goBack(type) {
  544. this.$emit("goBack", type);
  545. this.$emit('updateKey')
  546. },
  547. }
  548. }
  549. </script>
  550. <style lang="scss" scoped>
  551. ::v-deep .el-form-item {
  552. margin-bottom: 8px !important;
  553. }
  554. ::v-deep .el-table .cell {
  555. padding: 0 2px !important;
  556. .el-form-item {
  557. margin-bottom: 0px !important;
  558. }
  559. }
  560. ::v-deep .avue-crud .el-table .el-form-item__label {
  561. left: -1px;
  562. }
  563. ::v-deep#out-table .back-one {
  564. background: #ecf5ff !important;
  565. }
  566. ::v-deep#out-table .back-two {
  567. background: #ecf5ff !important;
  568. }
  569. </style>