index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. @search-criteria-switch="searchCriteriaSwitch"
  16. @refresh-change="refreshChange"
  17. @resetColumn="resetColumnTwo('crud','option','optionList',261)"
  18. @saveColumn="saveColumnTwo('crud','option','optionList',261)"
  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="corpIdsSearch" slot-scope="scope">
  26. <crop-select v-model="search.corpIds" corpType="KH"></crop-select>
  27. </template>
  28. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  29. <div style="display:flex;">
  30. <!-- <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">创建单据</el-button>-->
  31. <el-upload
  32. class="upload-demo"
  33. action="/api/blade-client/vehicleBrand/importBrand"
  34. :headers="headers"
  35. :on-error="onError"
  36. :on-success="onSuccess"
  37. :show-file-list="false"
  38. multiple>
  39. <el-button size="small" type="primary">导入品牌</el-button>
  40. </el-upload>
  41. <el-upload
  42. class="upload-demo"
  43. action="/api/blade-client/vehicleSeries/importSeries"
  44. :headers="headers"
  45. :on-error="onError"
  46. :on-success="onSuccess"
  47. :show-file-list="false"
  48. multiple>
  49. <el-button size="small" type="primary">导入车系</el-button>
  50. </el-upload>
  51. <el-upload
  52. class="upload-demo"
  53. action="/api/blade-client/vehicleModel/importModel"
  54. :headers="headers"
  55. :on-error="onError"
  56. :on-success="onSuccess"
  57. :show-file-list="false"
  58. multiple>
  59. <el-button size="small" type="primary">导入车型</el-button>
  60. </el-upload>
  61. </div>
  62. </template>
  63. </avue-crud>
  64. </basic-container>
  65. <!-- <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>-->
  66. </div>
  67. </template>
  68. <script>
  69. import {getList, remove} from "@/api/vehicleBrandAndModel.js";
  70. import {getToken} from "@/util/auth";
  71. // import detailsPage from "./detailsPage"
  72. export default {
  73. name: "index",
  74. components: {
  75. // detailsPage
  76. },
  77. data() {
  78. return {
  79. headers: { "Blade-Auth": "Bearer " + getToken() },
  80. detailsOpen: false,
  81. loading: false,
  82. search: {},
  83. form: {},
  84. dataList: [],
  85. detailData: {},
  86. page: {
  87. pageSize: 20,
  88. currentPage: 1,
  89. total: 0,
  90. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  91. },
  92. key:0,
  93. option: {},
  94. optionList: {
  95. viewBtn: false,
  96. editBtn: false,
  97. delBtn: false,
  98. addBtn: false,
  99. index: true,
  100. span: 8,
  101. border: true,
  102. height:"auto",
  103. searchMenuPosition: "right",
  104. align: "center",
  105. menu:false,
  106. menuWidth:140,
  107. searchSpan: 8,
  108. searchIcon: true,
  109. searchIndex: 2,
  110. highlightCurrentRow: true,
  111. dialogWidth: "70%",
  112. showSummary: true,
  113. sumColumnList: [{
  114. name: 'boxNumber',
  115. type: 'sum',
  116. decimals:0
  117. },{
  118. name: 'totalAmount',
  119. type: 'sum',
  120. decimals:2
  121. }],
  122. column: [{
  123. label: '品牌',
  124. prop: 'brand',
  125. width: 220,
  126. search: true
  127. },{
  128. label: "制单人",
  129. prop: "createUserName",
  130. searchProp:"createUser",
  131. overHidden: true,
  132. search: true,
  133. filterable: true,
  134. remote: true,
  135. type: "select",
  136. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  137. props: {
  138. label: "account",
  139. value: "id",
  140. res: 'data.records'
  141. }
  142. }, {
  143. label: "制单日期",
  144. prop: "createTime",
  145. searchProp:"createTimeList",
  146. type: "date",
  147. overHidden: true,
  148. searchRange: true,
  149. searchDefaultTime: ["00:00:00", "23:59:59"],
  150. format: "yyyy-MM-dd",
  151. valueFormat: "yyyy-MM-dd HH:mm:ss"
  152. }, {
  153. label: "更新人",
  154. prop: "updateUserName",
  155. searchProp:"updateUser",
  156. overHidden: true,
  157. search: true,
  158. filterable: true,
  159. remote: true,
  160. type: "select",
  161. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  162. props: {
  163. label: "account",
  164. value: "id",
  165. res: 'data.records'
  166. }
  167. }, {
  168. label: "更新日期",
  169. prop: "updateTime",
  170. searchProp:"updateTimeList",
  171. type: "date",
  172. overHidden: true,
  173. searchRange: true,
  174. searchDefaultTime: ["00:00:00", "23:59:59"],
  175. format: "yyyy-MM-dd",
  176. valueFormat: "yyyy-MM-dd HH:mm:ss"
  177. }]
  178. }
  179. }
  180. },
  181. activated() {
  182. if (this.$route.query.check) {
  183. this.detailsOpen = false
  184. this.detailData = {
  185. id: this.$route.query.check.billId,
  186. check: this.$route.query.check,
  187. };
  188. this.form = {
  189. id:this.$route.query.check.billId
  190. }
  191. this.detailsOpen = true
  192. this.$router.$avueRouter.closeTag(window.location.hash.slice(1))
  193. }
  194. },
  195. async created() {
  196. this.option = await this.getColumnData(this.getColumnName(261), this.optionList);
  197. this.key++
  198. let i = 0;
  199. this.option.column.forEach(item => {
  200. if (item.search) i++
  201. })
  202. if (i % 3 !== 0) {
  203. const num = 3 - Number(i % 3)
  204. this.option.searchMenuSpan = num * 8;
  205. this.option.searchMenuPosition = "right";
  206. }
  207. },
  208. methods: {
  209. onError(err, file, fileList){
  210. this.$message.error(JSON.parse(err.message).msg)
  211. },
  212. onSuccess(response, file, fileList){
  213. this.onLoad(this.page,this.search)
  214. },
  215. check(row){
  216. this.form = row
  217. this.detailsOpen = true
  218. },
  219. backToList(type) {
  220. this.form = {}
  221. this.detailsOpen = false
  222. if (type === 0){
  223. this.detailData = {}
  224. }
  225. this.onLoad(this.page,this.search)
  226. },
  227. searchCriteriaSwitch(type) {
  228. this.$refs.crud.getTableHeight();
  229. },
  230. //刷新
  231. refreshChange() {
  232. this.onLoad(this.page, this.search)
  233. },
  234. rowDel(form, index) {
  235. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  236. confirmButtonText: '确定',
  237. cancelButtonText: '取消',
  238. type: 'warning'
  239. }).then(() => {
  240. remove(form.id).then(res => {
  241. this.$message({
  242. type: 'success',
  243. message: '删除成功!'
  244. });
  245. })
  246. }).catch(() => {
  247. });
  248. },
  249. searchChange(params, done) {
  250. done();
  251. this.onLoad(this.page, params)
  252. },
  253. onLoad(page, params = {}) {
  254. params = {
  255. ...params,
  256. current: page.currentPage,
  257. size: page.pageSize,
  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>