receivable_list-add.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div>
  3. <div class="sty">
  4. <el-page-header @back="goBack"> </el-page-header>
  5. </div>
  6. <br />
  7. <span>基本信息</span>
  8. <el-divider></el-divider>
  9. <!-- 表头 -->
  10. <div>
  11. <el-form ref="searchForm" :rules="rulesForm" :model="searchForm" label-width="100px" size="small" label-position="left">
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="单据类型" prop="">
  15. <el-input v-model="searchForm.billType" disabled></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :xs="24" :sm="12" :lg="6">
  19. <el-form-item label="单据来源" prop="source">
  20. <el-select class="selectStyle" v-model="searchForm.source" placeholder="请选择">
  21. <el-option value="工程押金"> </el-option>
  22. <el-option value="保证金"> </el-option>
  23. <el-option value="工程价差"> </el-option>
  24. <el-option value="仓储费"> </el-option>
  25. </el-select>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :xs="24" :sm="12" :lg="6">
  29. <el-form-item label="业务日期" prop="">
  30. <el-date-picker disabled class="selectStyle" type="datetime" placeholder="系统自动生成" default-time="23:59:59" value-format="yyyy-MM-dd HH:mm:ss">
  31. </el-date-picker>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :xs="24" :sm="12" :lg="6">
  35. <el-form-item label="到期日" prop="endTime">
  36. <el-date-picker class="selectStyle" v-model="searchForm.endTime" type="datetime" placeholder="选择日期时间" default-time="23:59:59" value-format="yyyy-MM-dd HH:mm:ss">
  37. </el-date-picker>
  38. </el-form-item>
  39. </el-col>
  40. <!-- <el-col :xs="24" :sm="12" :lg="6">
  41. <el-form-item label="总金额" prop="">
  42. <el-input
  43. disabled
  44. v-model="searchForm.totalAmount"
  45. placeholder=""
  46. ></el-input>
  47. </el-form-item>
  48. </el-col> -->
  49. <el-col :xs="24" :sm="12" :lg="6">
  50. <el-form-item label="单据状态" prop="examineStatus">
  51. <el-select class="selectStyle" v-model="searchForm.examineStatus" placeholder="请选择">
  52. <el-option value="SAVE" label="暂存"> </el-option>
  53. </el-select>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :xs="24" :sm="12" :lg="6">
  57. <el-form-item label="备注" prop="">
  58. <el-input v-model="searchForm.remark" placeholder="请输入"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. </el-row>
  62. </el-form>
  63. </div>
  64. <span>明细</span>
  65. <el-divider></el-divider>
  66. <!-- 按钮 -->
  67. <div class="btn-group clearfix">
  68. <div class="fl">
  69. <el-popconfirm @onConfirm="delSeletFn" title="这是一段内容确定删除吗?">
  70. <el-button :disabled="selectList.length < 1" type="danger" size="mini" class="textColor delStyle" icon="el-icon-minus" slot="reference">批量删除</el-button>
  71. </el-popconfirm>
  72. </div>
  73. <div class="fr">
  74. <el-button type="primary" size="mini" @click="downLoadFn">模板</el-button>
  75. <el-upload class="import-btn" action="" :http-request="handleImport" :file-list="importFileList" :show-file-list="false">
  76. <el-button type="primary" size="mini">批量导入</el-button>
  77. </el-upload>
  78. </div>
  79. </div>
  80. <!-- 列表 -->
  81. <div class="mymain-container">
  82. <div class="table">
  83. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe @selection-change="selectionChange" :row-class-name="rouClassNameFn" @row-click="onRowClick">
  84. <!-- <el-table-column align="left" label="序号">
  85. <template slot-scope="scope">
  86. {{ scope.$index + 1 }}
  87. </template>
  88. </el-table-column> -->
  89. <el-table-column align="center" type="selection" width="51" show-overflow-tooltip></el-table-column>
  90. <el-table-column align="left" label="*经销商名称" prop="customerName" min-width="280" show-overflow-tooltip>
  91. <template slot-scope="scope">
  92. <el-select class="selectStyle" @change="changeCustomerFn($event, scope.$index)" v-model="scope.row.customerId" placeholder="请选择" filterable>
  93. <el-option v-for="(item, i) in customerList" :key="i" :label="item.name" :value="item.id">
  94. </el-option>
  95. </el-select>
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="left" label="费用项目编码" prop="projectCode" min-width="160" show-overflow-tooltip>
  99. <template slot-scope="scope">
  100. <el-input v-model="scope.row.projectCode"></el-input>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="left" label="*项目费用名称" prop="projectName" min-width="160" show-overflow-tooltip>
  104. <template slot-scope="scope">
  105. <el-input v-model="scope.row.projectName"></el-input>
  106. </template>
  107. </el-table-column>
  108. <el-table-column align="left" label="*费用承担部门" prop="departmentId" min-width="160" show-overflow-tooltip>
  109. <template slot-scope="scope">
  110. <el-input v-model="scope.row.departmentId"></el-input>
  111. </template>
  112. </el-table-column>
  113. <el-table-column align="left" label="*收入部门" prop="incomeDept" min-width="160" show-overflow-tooltip>
  114. <template slot-scope="scope">
  115. <el-input v-model="scope.row.incomeDept"></el-input>
  116. </template>
  117. </el-table-column>
  118. <el-table-column align="left" label="现金钱包" prop="walletId" min-width="160" show-overflow-tooltip>
  119. <template slot-scope="scope">
  120. <el-select filterable v-model="scope.row.customerWalletId" placeholder="请选择">
  121. <el-option v-for="item in scope.row.walletList" :key="item.customerWalletId" :label="item.customerWalletName" :value="item.customerWalletId">
  122. </el-option>
  123. </el-select>
  124. </template>
  125. </el-table-column>
  126. <el-table-column align="left" label="*发票类型" prop="invoiceType" min-width="160" show-overflow-tooltip>
  127. <template slot-scope="scope">
  128. <!-- <el-input v-model="scope.row.invoiceType"></el-input> -->
  129. <el-select filterable v-model="scope.row.invoiceType" placeholder="请选择">
  130. <el-option label="普通发票" value=""> </el-option>
  131. <el-option label="增值税发票" value="1"> </el-option>
  132. <el-option label="机票" value="P"> </el-option>
  133. <el-option label="火车票" value="R"> </el-option>
  134. <el-option label="其他运输票" value="O"> </el-option>
  135. <el-option label="其他" value="E"> </el-option>
  136. </el-select>
  137. </template>
  138. </el-table-column>
  139. <!-- <el-table-column
  140. align="center"
  141. label="不含税金额"
  142. prop="afterTaxAmount"
  143. min-width="160"
  144. show-overflow-tooltip
  145. >
  146. <template slot-scope="scope">
  147. <el-input
  148. v-model="scope.row.afterTaxAmount"
  149. type="number"
  150. ></el-input>
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. align="center"
  155. label="税额"
  156. prop="tax"
  157. min-width="160"
  158. show-overflow-tooltip
  159. >
  160. <template slot-scope="scope">
  161. <el-input type="number" v-model="scope.row.tax"></el-input>
  162. </template>
  163. </el-table-column> -->
  164. <el-table-column align="right" label="*总金额" prop="tax" min-width="160" show-overflow-tooltip>
  165. <template slot-scope="scope">
  166. <el-input class='mountclass' type="number" v-model="scope.row.totalAmount"></el-input>
  167. </template>
  168. </el-table-column>
  169. <el-table-column align="left" label="税率%" prop="" min-width="160" show-overflow-tooltip>
  170. <template slot-scope="scope">
  171. <el-input type="number" :min="0" oninput="if(value>100)value=100;if(value<0)value=0" v-model="scope.row.taxRate"></el-input>
  172. </template>
  173. </el-table-column>
  174. <el-table-column align="left" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  175. <template slot-scope="scope">
  176. <el-input v-model="scope.row.remark"></el-input>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. </div>
  181. </div>
  182. <!-- 按钮 -->
  183. <div class="btn-group clearfix">
  184. <div class="fl">
  185. <el-button type="primary" size="small" @click="addFn">提交审核</el-button>
  186. <el-button type="primary" size="small" @click="resetFn">重置</el-button>
  187. </div>
  188. <div class="fr">
  189. <el-button type="primary" size="small" @click="addRowFn">添加行</el-button>
  190. <el-button type="primary" size="small" @click="delRowFn">删除行</el-button>
  191. </div>
  192. </div>
  193. <!-- 提示 -->
  194. <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
  195. <ul class="ulStyle" v-for="(v, i) in messageList" :key="i">
  196. <li>{{ v }},现金钱包余额不足,请确认是否继续提交此单据</li>
  197. </ul>
  198. <span slot="footer" class="dialog-footer">
  199. <el-button @click="dialogVisibleCancel">取 消</el-button>
  200. <el-button type="primary" @click="dialogVisibleOK">确 定</el-button>
  201. </span>
  202. </el-dialog>
  203. </div>
  204. </template>
  205. <script>
  206. import {
  207. getCustomerList,
  208. getFinanceCustomerList,
  209. getFinanceOtherReceAdd,
  210. getFinanceOtherReceApply,
  211. getFinanceOtherReceList,
  212. } from "@/api/finance/receivable_list";
  213. import { downloadFiles, handleImport } from "@/utils/util";
  214. export default {
  215. data() {
  216. return {
  217. importFileList: [],
  218. messageList: [],
  219. dialogVisible: false,
  220. searchForm: {
  221. source: "",
  222. billType: "其他应收单",
  223. examineStatus: "SAVE",
  224. endTime: "",
  225. remark: "",
  226. },
  227. rulesForm: {
  228. source: [
  229. { required: true, trigger: "change", message: "请选择单据来源" },
  230. ],
  231. examineStatus: [
  232. { required: true, trigger: "change", message: "请选择单据状态" },
  233. ],
  234. endTime: [
  235. { required: true, trigger: "change", message: "请选择到期日期" },
  236. ],
  237. },
  238. dataList: [],
  239. customerList: [], //经销商数据
  240. listLoading: false, // 列表加载loading
  241. walletList: [], //现金钱包数据
  242. delIndex: null,
  243. selectList: [],
  244. };
  245. },
  246. created() {
  247. this.getCustomerList();
  248. },
  249. methods: {
  250. //删除
  251. delSeletFn() {
  252. // console.log(this.dataList);
  253. this.selectList.sort(function (a, b) {
  254. return b - a;
  255. });
  256. // console.log(this.selectList);
  257. for (let index = 0; index < this.selectList.length; index++) {
  258. // console.log(index);
  259. this.dataList.splice(this.selectList[index], 1);
  260. }
  261. },
  262. //选择项改变
  263. selectionChange(v) {
  264. // console.log(v);
  265. this.selectList = v.map((v) => v.index);
  266. // console.log(this.selectList);
  267. },
  268. // 导入
  269. async handleImport(param) {
  270. const file = param.file;
  271. const formData = new FormData();
  272. formData.append("file", file);
  273. let result = await handleImport("/finance/rece/import/data", formData);
  274. // console.log(result);
  275. this.importFileList = [];
  276. if (result.code == 200) {
  277. this.$message.success("导入成功");
  278. // this.dataList.unshift(result.data);
  279. this.searchForm.source = result.data.source;
  280. this.searchForm.endTime = result.data.endTime;
  281. // this.searchForm.examineStatus = result.data.examineStatus;
  282. this.searchForm.examineStatus = "暂存";
  283. this.searchForm.remark = result.data.remark;
  284. let Arr = result.data.items;
  285. for (let v = 0; v < Arr.length; v++) {
  286. const res = await getFinanceCustomerList({
  287. customerId: Arr[v].customerId,
  288. type: "COMMONLY",
  289. });
  290. this.dataList.push({
  291. customerNumber: Arr[v].customerNumber,
  292. customerName: Arr[v].customerName,
  293. customerId: Arr[v].customerId,
  294. projectCode: Arr[v].projectCode,
  295. projectName: Arr[v].projectName,
  296. departmentId: Arr[v].departmentId,
  297. customerWalletId: Arr[v].customerWalletId,
  298. invoiceType: Arr[v].invoiceType,
  299. incomeDept: Arr[v].incomeDept,
  300. totalAmount: Arr[v].totalAmount,
  301. taxRate: Arr[v].taxRate,
  302. walletId: Arr[v].valletId,
  303. walletList: res.data,
  304. remark: Arr[v].remark,
  305. });
  306. }
  307. } else {
  308. this.$message.error(result.message);
  309. // this.$message.error(1231);
  310. }
  311. },
  312. //下载模板
  313. async downLoadFn() {
  314. downloadFiles("/finance/other/rec/download");
  315. },
  316. //取消
  317. async dialogVisibleCancel() {
  318. this.dialogVisible = false;
  319. },
  320. //确定
  321. async dialogVisibleOK() {
  322. this.dialogVisible = false;
  323. await getFinanceOtherReceAdd({
  324. items: this.dataList,
  325. ...this.searchForm,
  326. isContinue: true,
  327. });
  328. const res = await getFinanceOtherReceList({ pageSize: 1, pageNum: 1 });
  329. await getFinanceOtherReceApply({ id: res.data.records[0].id });
  330. this.$message.success("提审成功");
  331. this.$emit("updateList");
  332. this.$parent.showPage = 1;
  333. this.resetFn();
  334. },
  335. // // 不含税金额改变事件
  336. // changeAfterTaxAmount(v, i, sl) {
  337. // // console.log(v, i);
  338. // // let rule = /(^-?[1-9](\d+)?(\.\d{1,2})?$)|(^-?0$)|(^-?\d\.\d{1,2}$)/;
  339. // // console.log();
  340. // // if (!rule.test(v)) {
  341. // // this.$message.error("请输入正确的不含税金额");
  342. // // return;
  343. // // }
  344. // //税额
  345. // let tax = (v * (sl / 100)).toFixed(2);
  346. // // console.log(tax, "税额");
  347. // //总金额
  348. // let totalAmount = (v * 1 + tax * 1).toFixed(2);
  349. // // console.log(totalAmount, "总金额");
  350. // this.$set(this.dataList[i], "tax", tax);
  351. // this.$set(this.dataList[i], "totalAmount", totalAmount);
  352. // },
  353. //重置
  354. resetFn() {
  355. this.searchForm = {};
  356. },
  357. rouClassNameFn({ row, rowIndex }) {
  358. //把每一行的索引放进row
  359. row.index = rowIndex;
  360. },
  361. onRowClick(row, event, column) {
  362. this.delIndex = row.index;
  363. },
  364. //删除行
  365. delRowFn() {
  366. this.dataList.splice(this.delIndex, 1);
  367. },
  368. //新增
  369. async addFn() {
  370. await this.$refs.searchForm.validate();
  371. if (this.dataList.length == 0) {
  372. this.$message.error("请添加数据");
  373. return;
  374. }
  375. let aaa = this.dataList.find((v) => {
  376. if (v.customerId == "") {
  377. this.$message.error("请选择经销商");
  378. return v;
  379. }
  380. if (v.departmentId == "") {
  381. this.$message.error("请输入费用承担部门");
  382. return v;
  383. }
  384. if (v.incomeDept == "") {
  385. this.$message.error("请输入收入部门");
  386. return v;
  387. }
  388. if (!v.customerWalletId) {
  389. this.$message.error("请选择现金钱包");
  390. return v;
  391. }
  392. if (v.totalAmount == "") {
  393. this.$message.error("请输入总金额");
  394. return v;
  395. }
  396. });
  397. console.log(aaa);
  398. if (aaa != undefined) {
  399. return;
  400. }
  401. // console.log(this.dataList, 7777);
  402. this.dataList.forEach((v) => {
  403. let res = this.customerList.filter((i) => i.id == v.customerId);
  404. console.log(res);
  405. v.customerName = res[0].name;
  406. v.customerNumber = res[0].number;
  407. let res2 = v.walletList.filter(
  408. (j) => j.customerWalletId == v.customerWalletId
  409. );
  410. // console.log(res2, "res2");
  411. // v.customerWalletId = res2[0].customerWalletId;
  412. v.walletId = res2[0].walletRebateId;
  413. });
  414. // console.log(this.dataList, 888888);
  415. let res = await getFinanceOtherReceAdd({
  416. items: this.dataList,
  417. ...this.searchForm,
  418. });
  419. if (res.code == 201) {
  420. this.dialogVisible = true;
  421. this.messageList = res.data;
  422. }
  423. if (res.code == 200) {
  424. const res = await getFinanceOtherReceList({ pageSize: 1, pageNum: 1 });
  425. await getFinanceOtherReceApply({ id: res.data.records[0].id });
  426. this.$message.success("提审成功");
  427. this.$emit("updateList");
  428. this.$parent.showPage = 1;
  429. this.resetFn();
  430. }
  431. },
  432. //选择经销商名称事件
  433. async changeCustomerFn(v, index) {
  434. console.log(v, 322311);
  435. const res = await getFinanceCustomerList({
  436. customerId: v,
  437. type: "COMMONLY",
  438. });
  439. this.$set(this.dataList[index], "walletList", res.data);
  440. console.log(this.dataList, "kkk");
  441. // this.walletList = res.data;
  442. },
  443. //获取经销商数据
  444. async getCustomerList() {
  445. const res = await getCustomerList({ pageNum: 1, pageSize: -1 });
  446. this.customerList = res.data.records;
  447. },
  448. //添加行数据
  449. addRowFn() {
  450. this.dataList.push({
  451. customerId: "",
  452. projectCode: "FYXM01_SYS",
  453. projectName: "材料成本",
  454. departmentId: "",
  455. customerWalletId: "",
  456. invoiceType: "",
  457. incomeDept: "",
  458. // afterTaxAmount: "",
  459. // tax: "",
  460. totalAmount: "",
  461. taxRate: 13,
  462. });
  463. },
  464. goBack() {
  465. this.$parent.showPage = 1;
  466. },
  467. },
  468. };
  469. </script>
  470. <style lang="scss" scoped>
  471. .import-btn {
  472. display: inline-block;
  473. margin-left: 10px;
  474. }
  475. ::v-deep .mountclass {
  476. input {
  477. text-align: right;
  478. }
  479. }
  480. ::v-deep .el-dialog__body {
  481. padding: 0 20px;
  482. }
  483. .selectStyle {
  484. width: 100%;
  485. }
  486. .mar {
  487. margin-top: 20px;
  488. }
  489. .ulStyle {
  490. list-style: simp-chinese-informal;
  491. li {
  492. height: 30px;
  493. line-height: 30px;
  494. }
  495. }
  496. </style>