index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud
  5. :option="option"
  6. :search.sync="search"
  7. v-model="form"
  8. :table-loading="loading"
  9. :data="dataList"
  10. ref="crud"
  11. :key="key"
  12. @on-load="onLoad"
  13. @search-change="searchChange"
  14. @row-del="rowDel"
  15. @refresh-change="refreshChange"
  16. @resetColumn="resetColumnTwo('crud','option','optionList',266)"
  17. @saveColumn="saveColumnTwo('crud','option','optionList',266)"
  18. :page.sync="page">
  19. <template slot-scope="{type,size,row,index}" slot="menu">
  20. <el-button :size="size" :type="type" @click="check(row)">查看</el-button>
  21. <el-button :size="size" :type="type" @click="$refs.crud.rowDel(row,index)">删除</el-button>
  22. </template>
  23. <template slot="corpNameSearch">
  24. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  25. </template>
  26. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  27. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">新增</el-button>
  28. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  29. </template>
  30. </avue-crud>
  31. </basic-container>
  32. <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>
  33. </div>
  34. </template>
  35. <script>
  36. import {getList, remove} from "@/api/oceanShipping/maritimeExport/index.js";
  37. import detailsPage from "./detailsPage"
  38. export default {
  39. name: "index",
  40. components: {
  41. detailsPage
  42. },
  43. data() {
  44. return {
  45. detailsOpen: false,
  46. loading: false,
  47. search: {},
  48. form: {},
  49. dataList: [],
  50. detailData: {},
  51. page: {
  52. pageSize: 20,
  53. currentPage: 1,
  54. total: 0,
  55. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  56. },
  57. key: 0,
  58. option: {},
  59. optionList: {
  60. viewBtn: false,
  61. editBtn: false,
  62. delBtn: false,
  63. addBtn: false,
  64. index: true,
  65. span: 8,
  66. border: true,
  67. height: "auto",
  68. searchMenuPosition: "right",
  69. align: "center",
  70. size: "small",
  71. menuWidth: 100,
  72. searchSpan: 8,
  73. searchIcon: true,
  74. searchIndex: 2,
  75. highlightCurrentRow: true,
  76. dialogWidth: "70%",
  77. column: [{
  78. label: '单据编号',
  79. prop: "sysNo",
  80. search: true,
  81. overHidden: true,
  82. }, {
  83. label: '合同号',
  84. prop: "contractNumber",
  85. search: true,
  86. overHidden: true,
  87. }, {
  88. label: "供应商",
  89. prop: "corpId",
  90. search: true,
  91. }, {
  92. label: '账户',
  93. prop: "accountId",
  94. search: true,
  95. overHidden: true,
  96. }, {
  97. label: '金额',
  98. prop: "amount",
  99. search: true,
  100. overHidden: true,
  101. }, {
  102. label: '付款日期',
  103. prop: "settlementDate",
  104. search: true,
  105. overHidden: true,
  106. }, {
  107. label: '状态',
  108. prop: "status",
  109. search: true,
  110. overHidden: true,
  111. }, {
  112. label: "制单人",
  113. prop: "createUserName",
  114. searchProp: "createUser",
  115. overHidden: true,
  116. width: 100,
  117. filterable: true,
  118. remote: true,
  119. type: "select",
  120. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  121. props: {
  122. label: "account",
  123. value: "id",
  124. res: 'data.records'
  125. }
  126. }, {
  127. label: "制单日期",
  128. prop: "createTime",
  129. searchProp: "createTimeList",
  130. type: "date",
  131. overHidden: true,
  132. width: 100,
  133. searchRange: true,
  134. searchDefaultTime: ["00:00:00", "23:59:59"],
  135. format: "yyyy-MM-dd",
  136. valueFormat: "yyyy-MM-dd HH:mm:ss"
  137. }, {
  138. label: "更新人",
  139. prop: "updateUserName",
  140. searchProp: "updateUser",
  141. overHidden: true,
  142. width: 100,
  143. filterable: true,
  144. remote: true,
  145. type: "select",
  146. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  147. props: {
  148. label: "account",
  149. value: "id",
  150. res: 'data.records'
  151. }
  152. }, {
  153. label: "更新日期",
  154. prop: "updateTime",
  155. searchProp: "updateTimeList",
  156. type: "date",
  157. overHidden: true,
  158. width: 100,
  159. searchRange: true,
  160. searchDefaultTime: ["00:00:00", "23:59:59"],
  161. format: "yyyy-MM-dd",
  162. valueFormat: "yyyy-MM-dd HH:mm:ss"
  163. }]
  164. }
  165. }
  166. },
  167. async created() {
  168. this.option = await this.getColumnData(this.getColumnName(266), this.optionList);
  169. this.key++
  170. let i = 0;
  171. this.option.column.forEach(item => {
  172. if (item.search) i++
  173. })
  174. if (i % 3 !== 0) {
  175. const num = 3 - Number(i % 3)
  176. this.option.searchMenuSpan = num * 8;
  177. this.option.searchMenuPosition = "right";
  178. }
  179. },
  180. methods: {
  181. check(row) {
  182. this.form = row
  183. this.detailsOpen = true
  184. },
  185. backToList(type) {
  186. this.form = {}
  187. this.detailsOpen = false
  188. if (type === 0) {
  189. this.detailData = {}
  190. }
  191. this.onLoad(this.page, this.search)
  192. },
  193. //刷新
  194. refreshChange() {
  195. this.onLoad(this.page, this.search)
  196. },
  197. rowDel(form, index) {
  198. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  199. confirmButtonText: '确定',
  200. cancelButtonText: '取消',
  201. type: 'warning'
  202. }).then(() => {
  203. remove(form.id).then(res => {
  204. this.$message({
  205. type: 'success',
  206. message: '删除成功!'
  207. });
  208. this.dataList.splice(index, 1);
  209. this.onLoad(this.page)
  210. })
  211. }).catch(() => {
  212. });
  213. },
  214. searchChange(params, done) {
  215. done();
  216. this.onLoad(this.page, params)
  217. },
  218. onLoad(page, params = {}) {
  219. params = {
  220. ...params,
  221. current: page.currentPage,
  222. size: page.pageSize,
  223. billType: "HYCK",
  224. ...Object.assign(params, this.search)
  225. }
  226. this.loading = true
  227. getList(params).then(res => {
  228. this.dataList = res.data.data.records
  229. this.page.total = res.data.data.total
  230. this.loading = false
  231. }).finally(() => {
  232. this.loading = false
  233. })
  234. },
  235. //自定义列保存
  236. async saveColumnTwo(ref, option, optionBack, code) {
  237. /**
  238. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  239. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  240. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  241. */
  242. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  243. if (inSave) {
  244. this.$message.success("保存成功");
  245. //关闭窗口
  246. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  247. }
  248. },
  249. //自定义列重置
  250. async resetColumnTwo(ref, option, optionBack, code) {
  251. this[option] = this[optionBack];
  252. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  253. if (inSave) {
  254. this.$message.success("重置成功");
  255. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  256. }
  257. }
  258. }
  259. }
  260. </script>
  261. <style scoped>
  262. </style>