receivable_list-add.vue 15 KB

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