financialAccount.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud
  5. ref="crud"
  6. :data="data"
  7. :option="option"
  8. :table-loading="loading"
  9. @row-update="rowUpdate"
  10. @row-del="rowDel"
  11. @saveColumn="saveColumn"
  12. @resetColumn="resetColumn"
  13. >
  14. <template slot="menuLeft" slot-scope="{size}">
  15. <el-button type="primary"
  16. icon="el-icon-plus"
  17. size="small"
  18. :loading="submitButton"
  19. @click="entering"
  20. >录入
  21. </el-button>
  22. </template>
  23. <template slot-scope="{row,index}" slot="menu">
  24. <!-- <el-button-->
  25. <!-- type="text"-->
  26. <!-- size="small"-->
  27. <!-- icon="el-icon-edit"-->
  28. <!-- @click="rowCell(row,index)"-->
  29. <!-- >{{ row.$cellEdit ? '修改完成' : '修改' }}-->
  30. <!-- </el-button>-->
  31. <el-button
  32. type="text"
  33. icon="el-icon-delete"
  34. size="small"
  35. @click="rowDel(row,index)"
  36. >删除
  37. </el-button>
  38. </template>
  39. <template slot-scope="{row,index}" slot="corpId">
  40. <span v-if="row.$cellEdit" class="required_fields" style="float: left;line-height: 32px">*</span>
  41. <crop-select
  42. v-if="row.$cellEdit"
  43. v-model="corpId"
  44. corpType="KG"
  45. style="width: 100%"
  46. ></crop-select>
  47. </template>
  48. <template slot-scope="{row,index}" slot="costType">
  49. <span v-if="row.$cellEdit" class="required_fields">*</span>
  50. <breakdown-select
  51. v-if="row.$cellEdit"
  52. v-model="row.costType"
  53. style="width: 90%"
  54. :configuration="configuration">
  55. </breakdown-select>
  56. <span v-else>{{ row.costType }}</span>
  57. </template>
  58. <template slot-scope="{row,index}" slot="billNo">
  59. <el-select placeholder="请选择"
  60. v-if="row.$cellEdit"
  61. v-model="row.billNo"
  62. size="small"
  63. filterable
  64. allow-create
  65. default-first-option
  66. clearable>
  67. <el-option
  68. v-for="item in row.billNoList"
  69. :key="item"
  70. :label="item"
  71. :value="item"
  72. ></el-option>
  73. </el-select>
  74. <span v-else>{{ row.billNo }}</span>
  75. </template>
  76. <template slot-scope="{row,index}" slot="taxRate">
  77. <el-input
  78. v-model="row.taxRate"
  79. v-if="row.$cellEdit"
  80. size="small"
  81. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  82. autocomplete="off"
  83. >
  84. <i slot="suffix" style="margin-right: 10px;top:6px">%</i>
  85. </el-input>
  86. <span v-else>{{ row.taxRate }}</span>
  87. </template>
  88. <template slot-scope="{row,index}" slot="currency">
  89. <span v-if="row.$cellEdit" class="required_fields">*</span>
  90. <el-select v-if="row.$cellEdit" v-model="row.currency" size="small" placeholder="请选择" style="width: 90%" @change="currencyChange(row)" clearable filterable>
  91. <el-option v-for="(item,index) in currencyDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  92. </el-select>
  93. <span v-else>{{ row.currency }}</span>
  94. </template>
  95. <template slot-scope="{row,index}" slot="unit">
  96. <span v-if="row.$cellEdit" class="required_fields">*</span>
  97. <el-select v-if="row.$cellEdit" v-model="row.unit" size="small" style="width: 90%" placeholder="请选择" clearable filterable>
  98. <el-option v-for="(item,index) in unitDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  99. </el-select>
  100. <span v-else>{{ row.unit }}</span>
  101. </template>
  102. </avue-crud>
  103. <div class="dialogButton">
  104. <el-button size="small" :loading="submitButton" @click="$emit('choceFun')">取消</el-button>
  105. <el-button type="primary" size="small" :loading="submitButton" @click="submit()">确定</el-button>
  106. </div>
  107. </basic-container>
  108. <containerTitle title="历史账单"></containerTitle>
  109. <basic-container>
  110. <avue-crud :option="historyOption"
  111. :data="historyDataList"
  112. ref="historyCrud"
  113. v-model="historyForm"
  114. :page.sync="page"
  115. :table-loading="historyLoading"
  116. @on-load="onLoad">
  117. </avue-crud>
  118. </basic-container>
  119. </div>
  120. </template>
  121. <script>
  122. import {applyLoan, paymentApply} from "@/api/financialManagement/paymentRequest";
  123. import option from "./config/option.json"
  124. import historyOption from "../bill/config/application.json"
  125. import {getUserInfo} from "@/api/system/user";
  126. import { getBillList } from "@/api/financialManagement/paymentRequest";
  127. export default {
  128. name: "financialAccount",
  129. props: {
  130. billId:{
  131. type:String
  132. },
  133. billType: {
  134. type: String
  135. },
  136. billData: {
  137. type: Object
  138. },
  139. choceFun: {
  140. type: Function
  141. },
  142. arrList: {
  143. type: Array,
  144. default: []
  145. },
  146. checkData: {
  147. type: Object,
  148. default: {
  149. url: null,
  150. pageStatus: null,
  151. pageLabel: null,
  152. checkType: null
  153. },
  154. },
  155. },
  156. data(){
  157. return {
  158. data: [],
  159. corpId:'',
  160. option:option,
  161. loading:false,
  162. submitButton:false,
  163. currencyDic:[],
  164. unitDic:[],
  165. configuration: {
  166. multipleChoices: false,
  167. multiple: false,
  168. disabled: true,
  169. searchShow: true,
  170. collapseTags: false,
  171. placeholder: '请点击右边按钮选择',
  172. dicData: []
  173. },
  174. category: '',
  175. historyLoading:false,
  176. historyOption:historyOption,
  177. historyDataList:[],
  178. historyForm:{},
  179. page: {
  180. pageSize: 10,
  181. pagerCount: 1,
  182. total: 0,
  183. },
  184. }
  185. },
  186. created() {
  187. this.historyOption.searchShow = false
  188. getUserInfo().then(res=>{
  189. this.category = res.data.data.billType
  190. if (this.category == 2) {
  191. }
  192. })
  193. //币别
  194. this.getWorkDicts("currency").then(res => {
  195. this.currencyDic = res.data.data
  196. })
  197. this.getWorkDicts("unit").then(res => {
  198. this.unitDic = res.data.data
  199. })
  200. },
  201. mounted() {
  202. this.init()
  203. },
  204. watch:{
  205. billId(val, oldVal) {
  206. if(val != oldVal){
  207. this.onLoad(this.page)
  208. }
  209. },
  210. },
  211. methods:{
  212. init(){
  213. if(this.arrList.length === 0){
  214. this.corpId = this.billData.corpId
  215. this.$refs.crud.rowCellAdd(this.billData);
  216. }else{
  217. this.billData = this.arrList[0]
  218. this.corpId = this.arrList[0].corpId
  219. this.arrList.forEach(item=>{
  220. this.$refs.crud.rowCellAdd(item);
  221. })
  222. }
  223. //删除 提单号
  224. if(this.billData.optionType !== "JK"){
  225. this.option.column.forEach(item =>{
  226. if(item.prop === "billNo"){
  227. item.hide = true
  228. }else{
  229. item.hide = false
  230. }
  231. })
  232. }
  233. },
  234. currencyChange(row){
  235. this.currencyDic.forEach(item =>{
  236. if(item.dictValue === row.currency){
  237. row.exchangeRate = item.remark
  238. }
  239. })
  240. },
  241. rowCell(row,index){
  242. this.$refs.crud.rowCell(row, index)
  243. },
  244. rowDel(row,index){
  245. this.$confirm("确定将选择数据删除?", {
  246. confirmButtonText: "确定",
  247. cancelButtonText: "取消",
  248. type: "warning"
  249. }).then(() => {
  250. this.data.splice(index, 1);
  251. })
  252. },
  253. rowUpdate(row, index, done, loading) {
  254. done(row);
  255. },
  256. entering(){
  257. if(this.data.length !== 0){
  258. //取第一条数据的 合同号 以及客户
  259. let params = {
  260. ...this.billData,
  261. srcOrderno:this.data[0].srcOrderno,
  262. corpId:this.data[0].corpId
  263. }
  264. this.$refs.crud.rowCellAdd(params);
  265. }else{
  266. this.$refs.crud.rowCellAdd(this.billData);
  267. }
  268. },
  269. onLoad(page,params = {}) {
  270. this.historyLoading = true;
  271. params.srcParentId = this.billId
  272. params.flag = 1
  273. getBillList(page.currentPage, page.pageSize,params).then(res=>{
  274. this.historyDataList = res.data.data.records
  275. }).finally(()=>{
  276. this.historyLoading = false;
  277. })
  278. },
  279. submit(){
  280. for(let i = 0;i<this.data.length;i++){
  281. if (this.corpId === (null || "")) {
  282. return this.$message.error(`请输入第${i + 1}行的客户`);
  283. }
  284. if (this.data[i].costType === (null || "")) {
  285. return this.$message.error(`请输入第${i + 1}行的费用名称`);
  286. }
  287. if (this.data[i].accDate === (null || "")) {
  288. return this.$message.error(`请输入第${i + 1}行的合同日期`);
  289. }
  290. if (this.data[i].amount === (null || "")) {
  291. return this.$message.error(`请输入第${i + 1}行的金额`);
  292. }
  293. if (this.data[i].currency === (null || "")) {
  294. return this.$message.error(`请输入第${i + 1}行的币别`);
  295. }
  296. if (this.data[i].exchangeRate === (null || "")) {
  297. return this.$message.error(`请输入第${i + 1}行的汇率`);
  298. }
  299. if (this.data[i].taxRate === (null || "")) {
  300. return this.$message.error(`请输入第${i + 1}行的税率`);
  301. }
  302. }
  303. this.submitButton = true
  304. const itemsList = this.data.map(item => {
  305. item.corpId = this.corpId;
  306. item.tradeType = this.billData.optionType?this.billData.optionType: item.tradeType
  307. // item.srcType = 1
  308. return item
  309. })
  310. const params = {
  311. url: this.checkData.url,
  312. pageStatus: this.checkData.pageStatus,
  313. pageLabel: this.checkData.pageLabel,
  314. checkType: this.checkData.checkType,
  315. billType : this.billType,
  316. DC : this.billData.itemType === "采购"?"C":"D", //账单明细会根据D C区分采购 销售搜索
  317. itemsList: itemsList
  318. }
  319. // 采购申请货款 销售申请退款 都会走申请 走审核 => 付款申请
  320. if(this.billType === "申请"){
  321. applyLoan(params).then(res =>{
  322. if(res.data.success){
  323. this.$message.success("操作成功!")
  324. this.$emit("choceFun");
  325. //跳转付款申请页面
  326. // if(this.$store.getters.pqStatus){
  327. // this.$alert("无法自动跳,因为付费申请页面已存在!", "温馨提示", {
  328. // confirmButtonText: "确定",
  329. // type: 'warning',
  330. // callback: action => {
  331. // }
  332. // });
  333. // }else{
  334. // //关闭一下存在的列表页 跳转
  335. // this.$router.$avueRouter.closeTag('/financialManagement/paymentRequest/index');
  336. // this.$router.push({
  337. // path: "/financialManagement/paymentRequest/index",
  338. // query: {params: res.data.data.id},
  339. // });
  340. // }
  341. }
  342. }).finally(()=>{
  343. this.submitButton = false
  344. })
  345. }
  346. //采购退款结算 销售收款结算 不需申请请核 直接结算 => 结算
  347. if(this.billType === "收费"){
  348. paymentApply(params).then(res=>{
  349. if(res.data.success){
  350. this.$message.success("操作成功!")
  351. this.$emit("choceFun");
  352. }
  353. }).finally(()=>{
  354. this.submitButton = false
  355. })
  356. }
  357. },
  358. saveColumn(){
  359. },
  360. resetColumn(){
  361. },
  362. }
  363. }
  364. </script>
  365. <style scoped lang="scss">
  366. .required_fields{
  367. color: #F56C6C;
  368. display:inline-block;
  369. width: 7%
  370. }
  371. </style>