index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option"
  5. :data="dataList"
  6. ref="crud"
  7. v-model="form"
  8. :page.sync="page"
  9. :search.sync="search"
  10. :table-loading="loading"
  11. @row-del="rowDel"
  12. :before-open="beforeOpen"
  13. :before-close="beforeClose"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad"
  21. @tree-load="treeLoad"
  22. @saveColumn="saveColumn">
  23. <template slot="menuLeft" slot-scope="{size}">
  24. <el-button type="success" :size="size" icon="el-icon-copy-document" @click="copyOrder" :disabled="single">复制新单</el-button>
  25. <el-button type="info" :size="size" icon="el-icon-printer">报 表</el-button>
  26. <el-button type="warning" :size="size" icon="el-icon-thumb" :disabled="multiple" @click="applyPayment">申请货款</el-button>
  27. </template>
  28. <template slot-scope="scope" slot="orgOrderNo">
  29. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.orgOrderNo }}</span>
  30. </template>
  31. <template slot="corpIdSearch">
  32. <select-component
  33. v-model="search.corpId"
  34. :configuration="configuration"
  35. ></select-component>
  36. </template>
  37. <template slot-scope="scope" slot="corpId">
  38. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.strCorpName }}</span>
  39. </template>
  40. <template slot-scope="scope" slot="createUser">
  41. {{ scope.row.createUserName }}
  42. </template>
  43. <template slot-scope="scope" slot="menu">
  44. <!-- <el-button-->
  45. <!-- type="text"-->
  46. <!-- icon="el-icon-view"-->
  47. <!-- size="small"-->
  48. <!-- @click.stop="beforeOpenPage(scope.row,scope.index)"-->
  49. <!-- >查看-->
  50. <!-- </el-button>-->
  51. <el-button
  52. type="text"
  53. icon="el-icon-edit"
  54. size="small"
  55. @click.stop="editOpen(scope.row,scope.index)"
  56. >编辑
  57. </el-button>
  58. <el-button
  59. type="text"
  60. icon="el-icon-delete"
  61. size="small"
  62. @click.stop="rowDel(scope.row,scope.index)"
  63. >删除
  64. </el-button>
  65. </template>
  66. </avue-crud>
  67. </basic-container>
  68. <detail-page
  69. ref="detail"
  70. @goBack="goBack"
  71. :detailData="detailData"
  72. v-else
  73. ></detail-page>
  74. <el-dialog
  75. title="账单"
  76. append-to-body
  77. class="el-dialogDeep"
  78. :visible.sync="applyPaymentDialog"
  79. width="60%"
  80. :close-on-click-modal="false"
  81. :destroy-on-close="true"
  82. :close-on-press-escape="false"
  83. v-dialog-drag
  84. >
  85. <apply-payment
  86. v-if="applyPaymentDialog"
  87. :billType="billType"
  88. :billData="billData"
  89. :arrList="applyPaymentList"
  90. @choceFun="choceFun"
  91. >
  92. </apply-payment>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import option from "./configuration/mainList.json";
  98. import {customerList, deleteDetails} from "@/api/basicData/purchaseOrder"
  99. import detailPage from "./detailsPageEdit";
  100. import { defaultDate } from "@/util/date";
  101. import ApplyPayment from "@/components/finance/applyPayment";
  102. export default {
  103. name: "customerInformation",
  104. props: {
  105. detailData: {
  106. type: Object
  107. }
  108. },
  109. components: {
  110. detailPage,
  111. ApplyPayment,
  112. },
  113. data() {
  114. return {
  115. configuration: {
  116. multipleChoices: false,
  117. multiple: false,
  118. collapseTags: false,
  119. placeholder: "请点击右边按钮选择",
  120. dicData: [],
  121. clearable: true,
  122. },
  123. search: {},
  124. loading: false,
  125. form: {},
  126. option: {},
  127. parentId: 0,
  128. dataList: [],
  129. page: {
  130. pageSize: 10,
  131. pagerCount: 5,
  132. total: 0,
  133. pageSizes: [10,50,100,200,300]
  134. },
  135. // 非单个禁用
  136. single: true,
  137. // 非多个禁用
  138. multiple: true,
  139. selection: [],
  140. isShow: true,
  141. detailData: {},
  142. billType:"申请", //账单类型
  143. billData:{}, //账单需要数据
  144. applyPaymentDialog:false,//生成账单组件
  145. applyPaymentList: [],
  146. }
  147. },
  148. async created() {
  149. this.search.requiredArrivalDate = defaultDate(1)
  150. this.option = option
  151. // this.option = await this.getColumnData(this.getColumnName(17), option);
  152. let i = 0;
  153. this.option.column.forEach(item => {
  154. if (item.search) i++
  155. })
  156. if (i % 3 !== 0){
  157. const num = 3 - Number(i % 3)
  158. this.option.searchMenuSpan = num * 8;
  159. this.option.searchMenuPosition = "right";
  160. }
  161. this.option.column.forEach(item => {
  162. if (item.pickerOptions) {
  163. item.pickerOptions = {
  164. shortcuts: [{
  165. text: '最近一周',
  166. onClick(picker) {
  167. const end = new Date();
  168. const start = new Date();
  169. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  170. picker.$emit('pick', [start, end]);
  171. }
  172. }, {
  173. text: '最近一个月',
  174. onClick(picker) {
  175. const end = new Date();
  176. const start = new Date();
  177. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  178. picker.$emit('pick', [start, end]);
  179. }
  180. }, {
  181. text: '最近三个月',
  182. onClick(picker) {
  183. const end = new Date();
  184. const start = new Date();
  185. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  186. picker.$emit('pick', [start, end]);
  187. }
  188. }]
  189. }
  190. }
  191. })
  192. },
  193. methods: {
  194. //删除列表后面的删除按钮触发触发(row, index, done)
  195. rowDel(row, index, done) {
  196. this.$confirm("确定将选择数据删除?", {
  197. confirmButtonText: "确定",
  198. cancelButtonText: "取消",
  199. type: "warning"
  200. }).then(() => {
  201. return deleteDetails(row.id);
  202. }).then(() => {
  203. this.$message({
  204. type: "success",
  205. message: "操作成功!"
  206. });
  207. this.page.currentPage = 1;
  208. this.onLoad(this.page, {parentId: 0});
  209. });
  210. },
  211. //查询全部
  212. initData() {
  213. customerList().then(res => {
  214. console.log(this.form);
  215. const column = this.findObject(this.option.column, "parentId");
  216. column.dicData = res.data.data.records;
  217. });
  218. },
  219. //新增子项触发
  220. handleAdd(row) {
  221. this.parentId = row.id;
  222. const column = this.findObject(this.option.column, "parentId");
  223. column.value = row.id;
  224. column.addDisabled = true;
  225. this.$refs.crud.rowAdd();
  226. },
  227. //查看跳转页面
  228. beforeOpenPage(row, index) {
  229. this.detailData = {
  230. id: row.id,
  231. seeDisabled: true,
  232. };
  233. this.isShow = false;
  234. },
  235. //新增跳转页面
  236. beforeOpen(row, index) {
  237. this.detailData = {
  238. id: row.id,
  239. };
  240. this.isShow = false;
  241. },
  242. editOpen(row, index) {
  243. this.detailData = {
  244. id: row.id,
  245. };
  246. this.isShow = false;
  247. },
  248. // 复制新单
  249. copyOrder() {
  250. const id = this.selection[0].id;
  251. this.detailData = {
  252. copyId: id,
  253. };
  254. this.isShow = false;
  255. },
  256. //点击新增时触发
  257. beforeClose(done) {
  258. this.parentId = "";
  259. const column = this.findObject(this.option.column, "parentId");
  260. column.value = "";
  261. column.addDisabled = false;
  262. done();
  263. },
  264. //点击搜索按钮触发
  265. searchChange(params, done) {
  266. if (params.requiredArrivalDate) {
  267. this.$set(params, 'requiredArrivalStartDate', params.requiredArrivalDate[0]+ " " + "00:00:00")
  268. this.$set(params, 'requiredArrivalEndDate', params.requiredArrivalDate[1]+ " " + "23:59:59")
  269. this.$delete(params,'requiredArrivalDate')
  270. }
  271. if (params.createTime) {
  272. params.createStartTime = params.createTime[0]+ " " + "00:00:00"
  273. params.createEndTime = params.createTime[1]+ " " + "23:59:59"
  274. this.$delete(params,'createTime')
  275. }
  276. this.page.currentPage = 1;
  277. this.onLoad(this.page, params);
  278. done()
  279. },
  280. searchReset() {
  281. console.log('1')
  282. },
  283. selectionChange(list) {
  284. console.log(list)
  285. this.selection = []
  286. this.selection = list;
  287. this.single = list.length !== 1;
  288. this.multiple = list.length == 0
  289. },
  290. currentChange() {
  291. console.log('1')
  292. },
  293. sizeChange() {
  294. console.log('1')
  295. },
  296. refreshChange() {
  297. console.log('1')
  298. },
  299. onLoad(page, params) {
  300. if (this.search.requiredArrivalDate.length > 0) {
  301. params = {
  302. ...params,
  303. requiredArrivalStartDate: this.search.requiredArrivalDate[0]+ " " + "00:00:00",
  304. requiredArrivalEndDate: this.search.requiredArrivalDate[1]+ " " + "23:59:59",
  305. }
  306. this.$delete(params,'requiredArrivalDate')
  307. }
  308. let queryParams = Object.assign({tradeType: 'GN'}, params, {
  309. size: page.pageSize,
  310. current: page.currentPage,
  311. // billType:'CG',
  312. // corpsTypeId: this.treeDeptId
  313. })
  314. this.loading = true;
  315. customerList(queryParams).then(res => {
  316. this.dataList = res.data.data.records
  317. this.page.total = res.data.data.total
  318. }).finally(() => {
  319. this.loading = false;
  320. })
  321. },
  322. //树桩列点击展开触发
  323. treeLoad(tree, treeNode, resolve) {
  324. const parentId = tree.id;
  325. customerList({parentId: parentId}).then(res => {
  326. resolve(res.data.data.records);
  327. });
  328. },
  329. goBack() {
  330. this.selection = []
  331. this.applyPaymentList = []
  332. this.single = true
  333. this.multiple = true
  334. this.detailData=this.$options.data().detailData
  335. this.isShow = true;
  336. },
  337. //列保存触发
  338. async saveColumn() {
  339. /**
  340. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  341. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  342. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  343. */
  344. const inSave = await this.saveColumnData(
  345. this.getColumnName(17),
  346. this.option
  347. );
  348. if (inSave) {
  349. this.$message.success("保存成功");
  350. //关闭窗口
  351. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  352. }
  353. },
  354. // 申请货款
  355. applyPayment() {
  356. this.applyPaymentList = []
  357. if (this.selection.length > 1) {
  358. for (let item in this.selection) {
  359. if (this.selection[0].corpId !== this.selection[item].corpId) {
  360. return this.$message.error('批量结算供应商必须一致')
  361. }
  362. }
  363. }
  364. let a = []
  365. console.log(this.selection)
  366. this.selection.forEach(item => {
  367. let form = {
  368. form: {
  369. srcOrderno:item.orderNo,
  370. itemType:"采购",
  371. corpsName:item.strCorpName,
  372. corpId:item.corpId,
  373. srcParentId: item.id,
  374. currency: 'CNY',
  375. exchangeRate: '1',
  376. taxRate: '0',
  377. accDate: item.businesDate,
  378. }
  379. }
  380. a.push(form)
  381. })
  382. this.applyPaymentList = [...a]
  383. // this.beforeBillData(true);
  384. this.applyPaymentDialog = true;
  385. },
  386. beforeBillData(type) {
  387. if(type){ //申请货款
  388. // this.billData.srcId = -1
  389. }
  390. },
  391. //关闭账单
  392. choceFun(){
  393. this.applyPaymentDialog = false
  394. },
  395. }
  396. }
  397. </script>
  398. <style scoped>
  399. </style>