receivable_list-add.vue 12 KB

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