receivable_list-add.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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. invoiceType: Arr[v].invoiceType ? Arr[v].invoiceType : "",
  300. incomeDept: Arr[v].incomeDept,
  301. totalAmount: Arr[v].totalAmount,
  302. taxRate: Arr[v].taxRate,
  303. walletId: Arr[v].valletId,
  304. walletList: res.data,
  305. remark: Arr[v].remark,
  306. });
  307. }
  308. } else {
  309. this.$message.error(result.message);
  310. // this.$message.error(1231);
  311. }
  312. },
  313. //下载模板
  314. async downLoadFn() {
  315. downloadFiles("/finance/other/rec/download");
  316. },
  317. //取消
  318. async dialogVisibleCancel() {
  319. this.dialogVisible = false;
  320. },
  321. //确定
  322. async dialogVisibleOK() {
  323. this.dialogVisible = false;
  324. await getFinanceOtherReceAdd({
  325. items: this.dataList,
  326. ...this.searchForm,
  327. isContinue: true,
  328. });
  329. const res = await getFinanceOtherReceList({ pageSize: 1, pageNum: 1 });
  330. await getFinanceOtherReceApply({ id: res.data.records[0].id });
  331. this.$message.success("提审成功");
  332. this.$emit("updateList");
  333. this.$parent.showPage = 1;
  334. this.resetFn();
  335. },
  336. // // 不含税金额改变事件
  337. // changeAfterTaxAmount(v, i, sl) {
  338. // // console.log(v, i);
  339. // // let rule = /(^-?[1-9](\d+)?(\.\d{1,2})?$)|(^-?0$)|(^-?\d\.\d{1,2}$)/;
  340. // // console.log();
  341. // // if (!rule.test(v)) {
  342. // // this.$message.error("请输入正确的不含税金额");
  343. // // return;
  344. // // }
  345. // //税额
  346. // let tax = (v * (sl / 100)).toFixed(2);
  347. // // console.log(tax, "税额");
  348. // //总金额
  349. // let totalAmount = (v * 1 + tax * 1).toFixed(2);
  350. // // console.log(totalAmount, "总金额");
  351. // this.$set(this.dataList[i], "tax", tax);
  352. // this.$set(this.dataList[i], "totalAmount", totalAmount);
  353. // },
  354. //重置
  355. resetFn() {
  356. this.searchForm = {};
  357. },
  358. rouClassNameFn({ row, rowIndex }) {
  359. //把每一行的索引放进row
  360. row.index = rowIndex;
  361. },
  362. onRowClick(row, event, column) {
  363. this.delIndex = row.index;
  364. },
  365. //删除行
  366. delRowFn() {
  367. this.dataList.splice(this.delIndex, 1);
  368. },
  369. //新增
  370. async addFn() {
  371. await this.$refs.searchForm.validate();
  372. if (this.dataList.length == 0) {
  373. this.$message.error("请添加数据");
  374. return;
  375. }
  376. let aaa = this.dataList.find((v) => {
  377. if (v.customerId == "") {
  378. this.$message.error("请选择经销商");
  379. return v;
  380. }
  381. if (v.departmentId == "") {
  382. this.$message.error("请输入费用承担部门");
  383. return v;
  384. }
  385. if (v.incomeDept == "") {
  386. this.$message.error("请输入收入部门");
  387. return v;
  388. }
  389. if (!v.customerWalletId) {
  390. this.$message.error("请选择现金钱包");
  391. return v;
  392. }
  393. if (v.totalAmount == "") {
  394. this.$message.error("请输入总金额");
  395. return v;
  396. }
  397. });
  398. console.log(aaa);
  399. if (aaa != undefined) {
  400. return;
  401. }
  402. // console.log(this.dataList, 7777);
  403. this.dataList.forEach((v) => {
  404. let res = this.customerList.filter((i) => i.id == v.customerId);
  405. console.log(res);
  406. v.customerName = res[0].name;
  407. v.customerNumber = res[0].number;
  408. let res2 = v.walletList.filter(
  409. (j) => j.customerWalletId == v.customerWalletId
  410. );
  411. // console.log(res2, "res2");
  412. // v.customerWalletId = res2[0].customerWalletId;
  413. v.walletId = res2[0].walletRebateId;
  414. });
  415. // console.log(this.dataList, 888888);
  416. let res = await getFinanceOtherReceAdd({
  417. items: this.dataList,
  418. ...this.searchForm,
  419. });
  420. if (res.code == 201) {
  421. this.dialogVisible = true;
  422. this.messageList = res.data;
  423. }
  424. if (res.code == 200) {
  425. const res = await getFinanceOtherReceList({ pageSize: 1, pageNum: 1 });
  426. await getFinanceOtherReceApply({ id: res.data.records[0].id });
  427. this.$message.success("提审成功");
  428. this.$emit("updateList");
  429. this.$parent.showPage = 1;
  430. this.resetFn();
  431. }
  432. },
  433. //选择经销商名称事件
  434. async changeCustomerFn(v, index) {
  435. console.log(v, 322311);
  436. const res = await getFinanceCustomerList({
  437. customerId: v,
  438. type: "COMMONLY",
  439. });
  440. this.$set(this.dataList[index], "walletList", res.data);
  441. console.log(this.dataList, "kkk");
  442. // this.walletList = res.data;
  443. },
  444. //获取经销商数据
  445. async getCustomerList() {
  446. const res = await getCustomerList({ pageNum: 1, pageSize: -1 });
  447. this.customerList = res.data.records;
  448. },
  449. //添加行数据
  450. addRowFn() {
  451. this.dataList.push({
  452. customerId: "",
  453. projectCode: "FYXM01_SYS",
  454. projectName: "材料成本",
  455. departmentId: "",
  456. customerWalletId: "",
  457. invoiceType: "",
  458. incomeDept: "",
  459. // afterTaxAmount: "",
  460. // tax: "",
  461. totalAmount: "",
  462. taxRate: 13,
  463. });
  464. },
  465. goBack() {
  466. this.$parent.showPage = 1;
  467. },
  468. },
  469. };
  470. </script>
  471. <style lang="scss" scoped>
  472. .import-btn {
  473. display: inline-block;
  474. margin-left: 10px;
  475. }
  476. ::v-deep .mountclass {
  477. input {
  478. text-align: right;
  479. }
  480. }
  481. ::v-deep .el-dialog__body {
  482. padding: 0 20px;
  483. }
  484. .selectStyle {
  485. width: 100%;
  486. }
  487. .mar {
  488. margin-top: 20px;
  489. }
  490. .ulStyle {
  491. list-style: simp-chinese-informal;
  492. li {
  493. height: 30px;
  494. line-height: 30px;
  495. }
  496. }
  497. </style>