index.vue 9.4 KB

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