index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. @selection-change="selectionChange"
  15. @row-del="rowDel"
  16. @refresh-change="refreshChange"
  17. @resetColumn="resetColumnTwo('crud','option','optionList',248)"
  18. @saveColumn="saveColumnTwo('crud','option','optionList',248)"
  19. :page.sync="page">
  20. <template slot-scope="{type,size,row,$index}" slot="menu">
  21. <el-button icon="el-icon-view" :size="size" :type="type" @click="check(row)">查看</el-button>
  22. <el-button icon="el-icon-delete" :size="size" v-if="row.status == 0" :type="type" @click="$refs.crud.rowDel(row,$index)">删除
  23. </el-button>
  24. </template>
  25. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  26. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">创建单据</el-button>
  27. <el-button class="el-icon-document-copy" type="success" size="small" :disabled="!(selectionList.length === 1)" @click="copyData">复制单据</el-button>
  28. <el-button class="el-icon-download" type="warning" 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/importTrade/importDeclaration.js";
  37. import detailsPage from "./detailsPage"
  38. import {getToken} from "@/util/auth";
  39. export default {
  40. name: "index",
  41. components: {
  42. detailsPage
  43. },
  44. data() {
  45. return {
  46. detailsOpen: false,
  47. loading: false,
  48. search: {},
  49. form: {},
  50. dataList: [],
  51. selectionList: [],
  52. detailData: {},
  53. page: {
  54. pageSize: 20,
  55. currentPage: 1,
  56. total: 0,
  57. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  58. },
  59. key:0,
  60. option: {},
  61. optionList: {
  62. viewBtn: false,
  63. editBtn: false,
  64. delBtn: false,
  65. addBtn: false,
  66. index: true,
  67. span: 8,
  68. selection: true,
  69. border: true,
  70. height:"auto",
  71. searchMenuPosition: "right",
  72. align: "center",
  73. menuWidth:140,
  74. searchSpan: 8,
  75. searchIcon: true,
  76. searchIndex: 2,
  77. highlightCurrentRow: true,
  78. dialogWidth: "70%",
  79. column: [{
  80. label: '申报日期',
  81. prop: 'declareDate',
  82. searchProp: 'declareDateList',
  83. width: 120,
  84. search: true,
  85. overHidden: true,
  86. type: "date",
  87. searchRange: true,
  88. searchDefaultTime: ["00:00:00", "23:59:59"],
  89. format: "yyyy-MM-dd",
  90. valueFormat: "yyyy-MM-dd HH:mm:ss"
  91. }, {
  92. label: '系统编号',
  93. prop: 'sysNo',
  94. search: true,
  95. overHidden: true,
  96. width: 170
  97. }, {
  98. label: '统一编号',
  99. prop: 'unifiedNumbering',
  100. width: 170,
  101. search: true,
  102. overHidden: true,
  103. }, {
  104. label: '预录入编号',
  105. prop: 'preEntryNo',
  106. search: true,
  107. overHidden: true,
  108. width: 170
  109. }, {
  110. label: '海关编号',
  111. prop: 'customsNo',
  112. width: 200,
  113. search: true,
  114. overHidden: true,
  115. }, {
  116. label: '提运单号',
  117. prop: 'deliveryNumbers',
  118. width: 120,
  119. search: true,
  120. overHidden: true,
  121. }, {
  122. label: '申报地海关',
  123. prop: 'customsDeclarationPlace',
  124. width: 120,
  125. filterable: true,
  126. type: 'select',
  127. dicUrl: "/api/blade-system/dict-biz/dictionary?code=customs",
  128. props: {
  129. label: "dictValue",
  130. value: "dictValue"
  131. },
  132. overHidden: true,
  133. search: true,
  134. }, {
  135. label: '状态',
  136. prop: 'status',
  137. width: 140,
  138. search: true,
  139. overHidden: true,
  140. filterable: true,
  141. type: 'select',
  142. dataType: 'number',
  143. dicUrl: "/api/blade-system/dict-biz/dictionary?code=declaration_status",
  144. props: {
  145. label: "dictValue",
  146. value: "dictKey"
  147. }
  148. }]
  149. }
  150. }
  151. },
  152. activated() {
  153. if (this.$route.query.check) {
  154. this.detailsOpen = false
  155. this.detailData = {
  156. id: this.$route.query.check.billId,
  157. check: this.$route.query.check,
  158. };
  159. this.form = {
  160. id:this.$route.query.check.billId
  161. }
  162. this.detailsOpen = true
  163. this.$router.$avueRouter.closeTag(window.location.hash.slice(1))
  164. }
  165. },
  166. async created() {
  167. this.option = await this.getColumnData(this.getColumnName(248), this.optionList);
  168. this.key++
  169. let i = 0;
  170. this.option.column.forEach(item => {
  171. if (item.search) i++
  172. })
  173. if (i % 3 !== 0) {
  174. const num = 3 - Number(i % 3)
  175. this.option.searchMenuSpan = num * 8;
  176. this.option.searchMenuPosition = "right";
  177. }
  178. },
  179. methods: {
  180. copyData(){
  181. this.form = {id:`复制${this.selectionList[0].id}`}
  182. this.detailsOpen = true
  183. },
  184. selectionChange(list){
  185. this.selectionList = list
  186. },
  187. outExport() {
  188. let config = {params: {...this.search}}
  189. if (config.params) {
  190. for (const propName of Object.keys(config.params)) {
  191. const value = config.params[propName];
  192. if (value !== null && typeof (value) !== "undefined") {
  193. if (value instanceof Array) {
  194. for (const key of Object.keys(value)) {
  195. let params = propName + '[' + key + ']';
  196. config.params[params] = value[key]
  197. }
  198. delete config.params[propName]
  199. }
  200. }
  201. }
  202. }
  203. const routeData = this.$router.resolve({
  204. path: '/api/blade-box-tube/declareCustoms/export', //跳转目标窗口的地址
  205. query: {
  206. ...config.params, //括号内是要传递给新窗口的参数
  207. importExportSigns: "BGCK"
  208. }
  209. })
  210. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  211. },
  212. check(row){
  213. this.form = row
  214. this.detailsOpen = true
  215. },
  216. backToList(type) {
  217. this.form = {}
  218. this.detailsOpen = false
  219. if (type === 0){
  220. this.detailData = {}
  221. }
  222. this.onLoad(this.page,this.search)
  223. },
  224. //刷新
  225. refreshChange() {
  226. this.onLoad(this.page, this.search)
  227. },
  228. rowDel(form, index) {
  229. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  230. confirmButtonText: '确定',
  231. cancelButtonText: '取消',
  232. type: 'warning'
  233. }).then(() => {
  234. remove(form.id).then(res => {
  235. this.$message({
  236. type: 'success',
  237. message: '删除成功!'
  238. });
  239. this.onLoad(this.page,this.search)
  240. })
  241. }).catch(() => {
  242. this.$message({
  243. type: 'info',
  244. message: '已取消!'
  245. });
  246. });
  247. },
  248. searchChange(params, done) {
  249. done();
  250. this.onLoad(this.page, params)
  251. },
  252. onLoad(page, params = {}) {
  253. params = {
  254. ...params,
  255. current: page.currentPage,
  256. size: page.pageSize,
  257. importExportSigns: "BGCK",
  258. ...Object.assign(params, this.search)
  259. }
  260. this.loading = true
  261. getList(params).then(res => {
  262. this.dataList = res.data.data.records
  263. this.page.total = res.data.data.total
  264. this.loading = false
  265. }).finally(() => {
  266. this.loading = false
  267. })
  268. },
  269. //自定义列保存
  270. async saveColumnTwo(ref, option, optionBack, code) {
  271. /**
  272. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  273. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  274. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  275. */
  276. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  277. if (inSave) {
  278. this.$message.success("保存成功");
  279. //关闭窗口
  280. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  281. }
  282. },
  283. //自定义列重置
  284. async resetColumnTwo(ref, option, optionBack, code) {
  285. this[option] = this[optionBack];
  286. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  287. if (inSave) {
  288. this.$message.success("重置成功");
  289. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  290. }
  291. }
  292. }
  293. }
  294. </script>
  295. <style scoped>
  296. </style>