detailsPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList(0)">返回列表
  7. </el-button>
  8. <el-button v-if="detailData.id" type="danger" style="border: none;background: none;color: red"
  9. icon="el-icon-arrow-left"
  10. @click="backToList(1)">返回审核列表
  11. </el-button>
  12. </div>
  13. <div class="add-customer-btn">
  14. <el-button class="el-button--small-yh" type="primary" size="small" :disabled="form.status>0"
  15. @click="editCustomer">保存数据
  16. </el-button>
  17. </div>
  18. </div>
  19. <trade-card title="基础资料" style="margin-top: 50px">
  20. <avue-form :option="optionForm" v-model="form" ref="form">
  21. </avue-form>
  22. </trade-card>
  23. <trade-card title="明细信息">
  24. <avue-crud
  25. :option="option"
  26. :data="dataList"
  27. v-model="formTwo"
  28. ref="crud"
  29. :key="key"
  30. :before-open="beforeOpen"
  31. @row-save="rowSave"
  32. @row-update="rowUpdate"
  33. @resetColumn="resetColumnTwo('crud','option','optionBack',257.1)"
  34. @saveColumn="saveColumnTwo('crud','option','optionBack',257.1)">
  35. <template slot="corpNameForm" slot-scope="scope">
  36. <crop-select v-model="formTwo.corpId" corpType="KH"
  37. @getCorpData="(row)=>{getGSData(row,['formTwo','corpName'])}"/>
  38. </template>
  39. <template slot="monthForm" slot-scope="scope">
  40. <el-input-number v-model="formTwo.month" :min="1" :max="12" placeholder="请输入 月" :controls="false"
  41. style="width: 100%;"></el-input-number>
  42. </template>
  43. <template slot-scope="{type,size,row,index,disabled}" slot="menu">
  44. <el-button icon="el-icon-edit" :size="size" :disabled="disabled" :type="type"
  45. @click="$refs.crud.rowEdit(row,index)">编辑
  46. </el-button>
  47. <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type"
  48. @click="rowDel(row,index,'MX')">删除
  49. </el-button>
  50. </template>
  51. <template slot="menuLeft" slot-scope="scope">
  52. <el-button class="el-icon-download" type="info" size="small" :disabled="!form.id" @click="openReport">
  53. 报表打印
  54. </el-button>
  55. </template>
  56. </avue-crud>
  57. </trade-card>
  58. <!-- 报表-->
  59. <report-dialog
  60. :switchDialog="switchDialog"
  61. :reportId="form.id"
  62. reportName="预算分析"
  63. @onClose="onClose()"
  64. />
  65. </div>
  66. </template>
  67. <script>
  68. import {
  69. detail,
  70. submit,
  71. tradingBoxItem,
  72. } from "@/api/annualBudget.js";
  73. import reportDialog from "@/components/report-dialog/main.vue";
  74. export default {
  75. name: "detailsPage",
  76. props: {
  77. onLoad: Object,
  78. detailData: Object
  79. },
  80. components: {
  81. reportDialog
  82. },
  83. data() {
  84. return {
  85. key: 0,
  86. switchDialog: false,
  87. form: {},
  88. formTwo: {},
  89. optionForm: {
  90. menuBtn: false,
  91. span: 6,
  92. column: [{
  93. label: '标题',
  94. prop: 'title',
  95. rules: [{
  96. required: true,
  97. message: " ",
  98. trigger: "blur"
  99. }]
  100. }, {
  101. label: "年份",
  102. prop: "particularYear",
  103. type: "year",
  104. dataType: 'string',
  105. valueFormat: "yyyy",
  106. width: 100,
  107. rules: [{
  108. required: true,
  109. message: " ",
  110. trigger: "blur"
  111. }]
  112. }]
  113. },
  114. option: {},
  115. optionBack: {
  116. align: 'center',
  117. index: true,
  118. selection: false,
  119. addBtnText: "录入明细",
  120. refreshBtn: false,
  121. addBtn: true,
  122. span: 8,
  123. addRowBtn: false,
  124. cellBtn: false,
  125. editBtn: false,
  126. height: 600,
  127. delBtn: false,
  128. menuWidth: 200,
  129. dialogTop: 25,
  130. dialogWidth: "80%",
  131. summaryText: "合计",
  132. showSummary: true,
  133. sumColumnList: [{
  134. name: "keter",
  135. type: "sum",
  136. decimals: 2
  137. }, {
  138. name: "drivemaster",
  139. type: "sum",
  140. decimals: 2
  141. }, {
  142. name: "luxxan",
  143. type: "sum",
  144. decimals: 2
  145. }, {
  146. name: "xcentway",
  147. type: "sum",
  148. decimals: 2
  149. }],
  150. column: [{
  151. label: "年份",
  152. prop: "year",
  153. type: "year",
  154. overHidden: true,
  155. valueFormat: "yyyy",
  156. width: 100,
  157. rules: [{
  158. required: true,
  159. message: " ",
  160. trigger: "blur"
  161. }]
  162. }, {
  163. label: "月",
  164. prop: "month",
  165. width: 100,
  166. controls: false,
  167. type: 'number',
  168. rules: [{
  169. required: true,
  170. message: " ",
  171. trigger: "blur"
  172. }]
  173. }, {
  174. label: "客户名称",
  175. prop: "corpName",
  176. overHidden: true,
  177. width: 100,
  178. rules: [{
  179. required: true,
  180. message: " ",
  181. trigger: "blur"
  182. }]
  183. }, {
  184. label: "欧记",
  185. prop: "keter",
  186. overHidden: true,
  187. type: 'number',
  188. value: 0,
  189. precision: 2,
  190. controls: false,
  191. width: 100,
  192. }, {
  193. label: "登马",
  194. prop: "drivemaster",
  195. overHidden: true,
  196. type: 'number',
  197. value: 0,
  198. precision: 2,
  199. controls: false,
  200. width: 100,
  201. }, {
  202. label: "路迈",
  203. prop: "luxxan",
  204. overHidden: true,
  205. type: 'number',
  206. value: 0,
  207. precision: 2,
  208. controls: false,
  209. width: 100,
  210. }, {
  211. label: "爱特路",
  212. prop: "xcentway",
  213. type: 'number',
  214. value: 0,
  215. precision: 2,
  216. controls: false,
  217. overHidden: true,
  218. width: 100,
  219. }, {
  220. label: "汇总",
  221. prop: "quantitySummary",
  222. type: 'number',
  223. value: 0,
  224. precision: 2,
  225. display: false,
  226. controls: false,
  227. overHidden: true,
  228. width: 100,
  229. }]
  230. },
  231. dataList: [],
  232. disabled: false,
  233. }
  234. },
  235. async created() {
  236. this.option = await this.getColumnData(this.getColumnName(257.1), this.optionBack);
  237. if (this.onLoad.id) {
  238. this.refresh(this.onLoad.id, true)
  239. }
  240. this.findObject(this.option.column, "keter").change =
  241. this.findObject(this.option.column, "drivemaster").change =
  242. this.findObject(this.option.column, "luxxan").change =
  243. this.findObject(this.option.column, "xcentway").change = (data) => {
  244. this.formTwo[data.column.prop] = data.value
  245. this.formTwo.quantitySummary = this.formTwo.keter + this.formTwo.drivemaster + this.formTwo.luxxan + this.formTwo.xcentway
  246. }
  247. this.key++
  248. },
  249. methods: {
  250. getGSData(row, type) {
  251. this[type[0]][type[1]] = row.cname
  252. },
  253. // 报表
  254. openReport() {
  255. this.switchDialog = !this.switchDialog;
  256. },
  257. // 报表关闭
  258. onClose(val) {
  259. this.switchDialog = val;
  260. },
  261. // 明细删除
  262. rowDel(row, index, type) {
  263. this.$confirm("确定将选择数据删除?", {
  264. confirmButtonText: "确定",
  265. cancelButtonText: "取消",
  266. type: "warning"
  267. }).then(() => {
  268. if (row.id) {
  269. tradingBoxItem(row.id).then(res => {
  270. if (res.data.success) {
  271. this.$message.success("操作成功!");
  272. this.dataList.splice(index, 1);
  273. }
  274. });
  275. } else {
  276. this.dataList.splice(index, 1);
  277. this.$message.success("操作成功!");
  278. }
  279. }
  280. );
  281. },
  282. refresh(id, type) {
  283. const loading = this.$loading({
  284. lock: true,
  285. text: '加载中',
  286. spinner: 'el-icon-loading',
  287. background: 'rgba(255,255,255,0.7)'
  288. });
  289. detail({id: id}).then(res => {
  290. this.form = res.data.data
  291. this.dataList = res.data.data.itemList
  292. loading.close();
  293. this.key++
  294. })
  295. },
  296. //新增修改
  297. editCustomer() {
  298. this.$refs["form"].validate((valid, done) => {
  299. done()
  300. if (valid) {
  301. let data = {
  302. ...this.form,
  303. itemList: this.dataList,
  304. }
  305. const loading = this.$loading({
  306. lock: true,
  307. text: '加载中',
  308. spinner: 'el-icon-loading',
  309. background: 'rgba(255,255,255,0.7)'
  310. });
  311. submit(data).then(res => {
  312. if (this.form.id) {
  313. this.$message.success("修改成功")
  314. } else {
  315. this.$message.success("新增成功")
  316. }
  317. loading.close();
  318. this.refresh(res.data.data.id)
  319. }).catch(() => {
  320. loading.close();
  321. })
  322. }
  323. });
  324. },
  325. rowSave(form, done, loading) {
  326. done(form)
  327. },
  328. rowUpdate(form, index, done, loading) {
  329. done(form)
  330. },
  331. beforeOpen(done, type) {
  332. if (!['view', 'edit'].includes(type)) {
  333. this.formTwo.year = this.form.particularYear
  334. }
  335. done();
  336. },
  337. backToList(type) {
  338. if (type == 0) {
  339. if (this.detailData.id) {
  340. this.$router.push({
  341. path: '/boxManagement/exportShipment/index'
  342. });
  343. }
  344. this.$emit("backToList", type);
  345. } else if (type == 1) {
  346. this.$router.push({
  347. path: '/approveData/index'
  348. });
  349. this.$emit("backToList", type);
  350. }
  351. },
  352. //自定义列保存
  353. async saveColumnTwo(ref, option, optionBack, code) {
  354. /**
  355. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  356. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  357. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  358. */
  359. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  360. if (inSave) {
  361. this.$message.success("保存成功");
  362. //关闭窗口
  363. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  364. }
  365. },
  366. //自定义列重置
  367. async resetColumnTwo(ref, option, optionBack, code) {
  368. this[option] = this[optionBack];
  369. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  370. if (inSave) {
  371. this.$message.success("重置成功");
  372. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  373. this.findObject(this.option.column, "keter").change = this.findObject(this.option.column, "drivemaster").change = this.findObject(this.option.column, "luxxan").change = this.findObject(this.option.column, "xcentway").change = (data) => {
  374. this.formTwo[data.column.prop] = data.value
  375. this.formTwo.quantitySummary = this.formTwo.keter + this.formTwo.drivemaster + this.formTwo.luxxan + this.formTwo.xcentway
  376. }
  377. }
  378. }
  379. }
  380. }
  381. </script>
  382. <style scoped>
  383. ::v-deep .el-form-item {
  384. margin-bottom: 8px;
  385. }
  386. </style>