detailsPage.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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="goBack(0)">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <el-button v-if="editButton" class="el-button&#45;&#45;small-yh" style="margin-left: 6px;" type="primary"
  11. size="small" @click="editButton = false">编 辑
  12. </el-button>
  13. <el-button v-if="!editButton" style="margin-left: 6px;" type="primary" size="small" @click="submit">保 存
  14. </el-button>
  15. <el-button v-if="!editButton" type="success" size="small" @click="importData">导入明细科目名称</el-button>
  16. </div>
  17. </div>
  18. <div style="margin-top: 50px">
  19. <trade-card title="基础信息">
  20. <avue-form :option="optionForm" v-model="form" ref="form">
  21. </avue-form>
  22. </trade-card>
  23. <trade-card title="明细信息">
  24. <avue-crud ref="crud" :option="option" :data="form.accItems"
  25. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 368)"
  26. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 368)"
  27. @selection-change="selectionChange"></avue-crud>
  28. </trade-card>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import {
  34. getDetails, submit, getAccountsItemsList
  35. } from "@/api/iosBasicData/periodManagement";
  36. import reportDialog from "@/components/report-dialog/main";
  37. import { dateFormat } from "@/util/date";
  38. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  39. import _ from "lodash";
  40. export default {
  41. name: "detailsPage",
  42. data() {
  43. return {
  44. editButton: true,
  45. selectionList: [],
  46. bigObj: {},
  47. form: {},
  48. optionForm: {
  49. menuBtn: false,
  50. span: 6,
  51. labelWidth: 90,
  52. disabled: false,
  53. column: [
  54. {
  55. label: '凭证类型',
  56. prop: "vkno",
  57. disabled: false,
  58. },
  59. {
  60. label: '汇兑损益科目',
  61. prop: "plAccFnm",
  62. disabled: false,
  63. },
  64. {
  65. label: '摘要',
  66. prop: "descr",
  67. disabled: false,
  68. }
  69. ]
  70. },
  71. option: {},
  72. optionList: {
  73. disabled: false,
  74. border: true,
  75. align: 'center',
  76. // index: true,
  77. refreshBtn: false,
  78. addBtn: false,
  79. cellBtn: true,
  80. addRowBtn: false,
  81. editBtn: false,
  82. delBtn: false,
  83. menuWidth: 120,
  84. menu: false,
  85. tip: false,
  86. selection: true,
  87. column: [{
  88. label: '科目代码',
  89. prop: 'accNo',
  90. overHidden: true,
  91. display: false
  92. }, {
  93. label: '科目名称',
  94. prop: 'cnm',
  95. overHidden: true,
  96. display: false
  97. }, {
  98. label: '方向',
  99. prop: 'dc',
  100. overHidden: true,
  101. display: false
  102. }, {
  103. label: '币种',
  104. prop: 'fcyNo',
  105. overHidden: true,
  106. display: false
  107. }]
  108. }
  109. }
  110. },
  111. components: { SearchQuery, reportDialog },
  112. props: {
  113. onLoad: Object,
  114. detailData: Object
  115. },
  116. async created() {
  117. if (this.detailData.id) {
  118. this.editButton = true
  119. this.optionForm.disabled = true
  120. this.getDetail(this.detailData.id, this.detailData.type)
  121. }
  122. this.option = await this.getColumnData(this.getColumnName(368), this.optionList);
  123. },
  124. methods: {
  125. selectionChange(list) {
  126. this.selectionList = list
  127. },
  128. //修改提交触发
  129. submit() {
  130. this.$refs["form"].validate((valid, done) => {
  131. done();
  132. if (valid) {
  133. const loading = this.$loading({
  134. lock: true,
  135. text: '加载中',
  136. spinner: 'el-icon-loading',
  137. background: 'rgba(255,255,255,0.7)'
  138. });
  139. this.form.accItems.forEach(item => {
  140. item.selected = 'false'
  141. })
  142. this.selectionList.forEach(e => {
  143. this.form.accItems.forEach(item => {
  144. if (item.id == e.id) {
  145. item.selected = 'true'
  146. }
  147. })
  148. })
  149. let obj = {
  150. ...this.bigObj,
  151. periodVouchersTemplate: this.form
  152. }
  153. submit(obj).then(res => {
  154. this.form = res.data.data
  155. this.$message.success("保存成功");
  156. this.editButton = true;
  157. this.getDetail(this.form.periodVouchersTemplate.id, this.form.periodVouchersTemplate.bsType)
  158. }).finally(() => {
  159. loading.close();
  160. });
  161. } else {
  162. return false;
  163. }
  164. });
  165. },
  166. getDetail(id, type) {
  167. const loading = this.$loading({
  168. lock: true,
  169. text: '加载中',
  170. spinner: 'el-icon-loading',
  171. background: 'rgba(255,255,255,0.7)'
  172. })
  173. getDetails({ id: id, type: type }).then(res => {
  174. this.bigObj = res.data.data
  175. this.form = res.data.data.periodVouchersTemplate
  176. }).catch(() => {
  177. }).finally(() => {
  178. loading.close();
  179. this.form.accItems.forEach((e, index) => {
  180. if (e.selected == 'true') {
  181. this.$refs.crud.toggleRowSelection(e);
  182. }
  183. })
  184. });
  185. },
  186. importData() {
  187. this.$confirm('是否导入科目明细总账?', '提示', {
  188. confirmButtonText: '确定',
  189. cancelButtonText: '取消',
  190. type: 'warning'
  191. }).then(() => {
  192. getAccountsItemsList({ type: this.form.bsType == 'FM-CURRENCY-PL-TRANSFER' ? 1 : 2 }).then(res => {
  193. this.form.accItems = res.data.data
  194. this.$message.success("导入成功");
  195. }).finally(() => {
  196. this.form.accItems.forEach((e, index) => {
  197. if (e.selected == 'true') {
  198. this.$refs.crud.toggleRowSelection(e);
  199. }
  200. })
  201. });
  202. })
  203. },
  204. //自定义列保存
  205. async saveColumnTwo(ref, option, optionBack, code) {
  206. /**
  207. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  208. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  209. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  210. */
  211. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  212. if (inSave) {
  213. this.$message.success("保存成功");
  214. //关闭窗口
  215. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  216. }
  217. },
  218. //自定义列重置
  219. async resetColumnTwo(ref, option, optionBack, code) {
  220. this[option] = this[optionBack];
  221. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  222. if (inSave) {
  223. this.$message.success("重置成功");
  224. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  225. }
  226. },
  227. goBack(type) {
  228. this.$emit("goBack", type);
  229. },
  230. // 弹框的重置
  231. resetCrud() {
  232. this.$message.success("重置成功");
  233. },
  234. // 弹窗的保存
  235. saveCrud() {
  236. this.$message.success("保存成功");
  237. },
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. ::v-deep .el-form-item {
  243. margin-bottom: 8px !important;
  244. }
  245. </style>