index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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',243)"
  17. @saveColumn="saveColumnTwo('crud','option','optionList',243)"
  18. :page.sync="page">
  19. <template slot="addressSearch">
  20. <port-info v-model="search.addressId" type="id"/>
  21. </template>
  22. <template slot="companySearch" slot-scope="scope">
  23. <crop-select v-model="search.companyId" corpType="GS"/>
  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"
  28. @click="$refs.crud.rowDel(row,$index)">删除
  29. </el-button>
  30. </template>
  31. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  32. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">创建单据</el-button>
  33. <el-button class="el-icon-document-copy" type="success" size="small">复制单据</el-button>
  34. <el-button class="el-icon-download" type="warning" size="small" @click="outExport">导出</el-button>
  35. </template>
  36. </avue-crud>
  37. </basic-container>
  38. <detailsPage v-if="detailsOpen" :onLoad="form" @backToList="backToList" :detailData="detailData"></detailsPage>
  39. </div>
  40. </template>
  41. <script>
  42. import {getList, remove} from "@/api/boxManagement/boxRepair/index.js";
  43. import detailsPage from "./detailsPage"
  44. import {getToken} from "@/util/auth";
  45. export default {
  46. name: "index",
  47. components: {
  48. detailsPage
  49. },
  50. data() {
  51. return {
  52. detailsOpen: false,
  53. loading: false,
  54. search: {},
  55. detailData: {},
  56. form: {},
  57. dataList: [],
  58. page: {
  59. pageSize: 20,
  60. currentPage: 1,
  61. total: 0,
  62. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  63. },
  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. showSummary: true,
  83. sumColumnList: [{
  84. name: 'boxNumber',
  85. type: 'sum',
  86. decimals:0
  87. }],
  88. column: [{
  89. label: '系统号',
  90. prop: 'sysNo',
  91. overHidden: true
  92. },{
  93. label: '箱数',
  94. prop: 'boxNumber',
  95. width: 80,
  96. }, {
  97. label: '客户',
  98. prop: 'company',
  99. search: true,
  100. overHidden: true
  101. }, {
  102. label: '地点',
  103. prop: 'address',
  104. search: true,
  105. overHidden: true
  106. }, {
  107. label: '业务日期',
  108. prop: 'newDate',
  109. searchProp: 'newDateList',
  110. search: true,
  111. overHidden: true,
  112. type: "date",
  113. searchRange: true,
  114. searchDefaultTime: ["00:00:00", "23:59:59"],
  115. format: "yyyy-MM-dd",
  116. valueFormat: "yyyy-MM-dd HH:mm:ss"
  117. }, {
  118. label: '备注',
  119. prop: 'remarks',
  120. overHidden: true
  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: "createUserName",
  137. searchProp:"createUser",
  138. overHidden: true,
  139. width: 100,
  140. search: true,
  141. filterable: true,
  142. remote: true,
  143. type: "select",
  144. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  145. props: {
  146. label: "account",
  147. value: "id",
  148. res: 'data.records'
  149. }
  150. }, {
  151. label: "制单日期",
  152. prop: "createTime",
  153. searchProp:"createTimeList",
  154. type: "date",
  155. overHidden: true,
  156. width: 200,
  157. searchRange: true,
  158. searchDefaultTime: ["00:00:00", "23:59:59"],
  159. format: "yyyy-MM-dd",
  160. valueFormat: "yyyy-MM-dd HH:mm:ss"
  161. }, {
  162. label: "更新人",
  163. prop: "updateUserName",
  164. searchProp:"updateUser",
  165. overHidden: true,
  166. width: 100,
  167. search: true,
  168. filterable: true,
  169. remote: true,
  170. type: "select",
  171. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  172. props: {
  173. label: "account",
  174. value: "id",
  175. res: 'data.records'
  176. }
  177. }, {
  178. label: "更新日期",
  179. prop: "updateTime",
  180. searchProp:"updateTimeList",
  181. type: "date",
  182. overHidden: true,
  183. width: 200,
  184. searchRange: true,
  185. searchDefaultTime: ["00:00:00", "23:59:59"],
  186. format: "yyyy-MM-dd",
  187. valueFormat: "yyyy-MM-dd HH:mm:ss"
  188. }]
  189. },
  190. key:0
  191. }
  192. },
  193. activated() {
  194. if (this.$route.query.check) {
  195. this.detailsOpen = false
  196. this.detailData = {
  197. id: this.$route.query.check.billId,
  198. check: this.$route.query.check,
  199. };
  200. this.form = {
  201. id: this.$route.query.check.billId
  202. }
  203. this.detailsOpen = true
  204. this.$router.$avueRouter.closeTag(window.location.hash.slice(1))
  205. }
  206. },
  207. async created() {
  208. this.option = await this.getColumnData(this.getColumnName(243), this.optionList);
  209. this.key++
  210. let i = 0;
  211. this.option.column.forEach(item => {
  212. if (item.search) i++
  213. })
  214. if (i % 3 !== 0) {
  215. const num = 3 - Number(i % 3)
  216. this.option.searchMenuSpan = num * 8;
  217. this.option.searchMenuPosition = "right";
  218. }
  219. },
  220. methods: {
  221. check(row) {
  222. this.form = row
  223. this.detailsOpen = true
  224. },
  225. backToList(type) {
  226. this.form = {}
  227. this.detailsOpen = false
  228. if (type === 0) {
  229. this.detailData = {}
  230. }
  231. this.onLoad(this.page, this.search)
  232. },
  233. //刷新
  234. refreshChange() {
  235. this.onLoad(this.page, this.search)
  236. },
  237. rowDel(form, index) {
  238. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  239. confirmButtonText: '确定',
  240. cancelButtonText: '取消',
  241. type: 'warning'
  242. }).then(() => {
  243. remove(form.id).then(res => {
  244. this.$message({
  245. type: 'success',
  246. message: '删除成功!'
  247. });
  248. })
  249. }).catch(() => {
  250. });
  251. },
  252. searchChange(params, done) {
  253. done();
  254. this.onLoad(this.page, params)
  255. },
  256. onLoad(page, params = {}) {
  257. params = {
  258. ...params,
  259. current: page.currentPage,
  260. size: page.pageSize,
  261. billType: "WASH",
  262. ...Object.assign(params, this.search)
  263. }
  264. this.loading = true
  265. getList(params).then(res => {
  266. this.dataList = res.data.data.records
  267. this.page.total = res.data.data.total
  268. this.loading = false
  269. }).finally(() => {
  270. this.loading = false
  271. })
  272. },
  273. outExport() {
  274. let config = {params: {...this.search}}
  275. if (config.params) {
  276. for (const propName of Object.keys(config.params)) {
  277. const value = config.params[propName];
  278. if (value !== null && typeof (value) !== "undefined") {
  279. if (value instanceof Array) {
  280. for (const key of Object.keys(value)) {
  281. let params = propName + '[' + key + ']';
  282. config.params[params] = value[key]
  283. }
  284. delete config.params[propName]
  285. }
  286. }
  287. }
  288. }
  289. const routeData = this.$router.resolve({
  290. path: '/api/blade-box-tube/repair/exportRepairOut', //跳转目标窗口的地址
  291. query: {
  292. billType: "WASH",
  293. ...config.params //括号内是要传递给新窗口的参数
  294. }
  295. })
  296. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  297. },
  298. //自定义列保存
  299. async saveColumnTwo(ref, option, optionBack, code) {
  300. /**
  301. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  302. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  303. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  304. */
  305. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  306. if (inSave) {
  307. this.$message.success("保存成功");
  308. //关闭窗口
  309. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  310. }
  311. },
  312. //自定义列重置
  313. async resetColumnTwo(ref, option, optionBack, code) {
  314. this[option] = this[optionBack];
  315. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  316. if (inSave) {
  317. this.$message.success("重置成功");
  318. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  319. }
  320. }
  321. }
  322. }
  323. </script>
  324. <style scoped>
  325. </style>