index.vue 8.7 KB

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