index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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',235)"
  17. @saveColumn="saveColumnTwo('crud','option','optionList',235)"
  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/buyContainer/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. switchDialog: false,
  52. detailsOpen: false,
  53. loading: false,
  54. search: {},
  55. form: {},
  56. dataList: [],
  57. detailData: {},
  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. key:0,
  65. option: {},
  66. optionList: {
  67. viewBtn: false,
  68. editBtn: false,
  69. delBtn: false,
  70. addBtn: false,
  71. index: true,
  72. span: 8,
  73. border: true,
  74. height:"auto",
  75. searchMenuPosition: "right",
  76. align: "center",
  77. menuWidth:140,
  78. searchSpan: 8,
  79. searchIcon: true,
  80. searchIndex: 2,
  81. highlightCurrentRow: true,
  82. dialogWidth: "70%",
  83. showSummary: true,
  84. sumColumnList: [{
  85. name: 'boxNumber',
  86. type: 'sum',
  87. decimals:0
  88. }],
  89. column: [{
  90. label: '系统号',
  91. prop: 'sysNo',
  92. width: 220,
  93. search: true,
  94. searchOrder:2,
  95. }, {
  96. label: '箱号',
  97. prop: 'code',
  98. width: 100,
  99. searchOrder:1,
  100. overHidden: true,
  101. filterable: true,
  102. remote: true,
  103. type: "select",
  104. search: true,
  105. allowCreate: true,
  106. dicUrl: "/api/blade-box-tube/archives/list?size=10&current=1&code={{key}}",
  107. props: {
  108. label: "code",
  109. value: "code",
  110. res:"data.records"
  111. }
  112. },{
  113. label: '箱数',
  114. prop: 'boxNumber',
  115. width: 80,
  116. }, {
  117. label: '合同号',
  118. prop: 'contractNo',
  119. width: 170,
  120. search: true,
  121. searchOrder:1,
  122. }, {
  123. label: '买入公司',
  124. prop: 'purchaseCompanyId',
  125. width: 300,
  126. search: true,
  127. searchOrder:1,
  128. }, {
  129. label: '买入日期',
  130. prop: 'purchaseDate',
  131. width: 100,
  132. search: true,
  133. searchOrder:1,
  134. searchProp: 'purchaseDateList',
  135. overHidden: true,
  136. type: "date",
  137. searchRange: true,
  138. searchDefaultTime: ["00:00:00", "23:59:59"],
  139. format: "yyyy-MM-dd",
  140. valueFormat: "yyyy-MM-dd HH:mm:ss"
  141. }, {
  142. label: '状态',
  143. prop: 'status',
  144. width: 140,
  145. overHidden: true,
  146. filterable: true,
  147. type: 'select',
  148. dataType: 'number',
  149. dicUrl: "/api/blade-system/dict-biz/dictionary?code=approval_status",
  150. props: {
  151. label: "dictValue",
  152. value: "dictKey"
  153. }
  154. }, {
  155. label: '备注',
  156. prop: 'remarks',
  157. width: 500,
  158. search: true,
  159. searchOrder:1,
  160. }, {
  161. label: "制单人",
  162. prop: "createUserName",
  163. searchProp:"createUser",
  164. overHidden: true,
  165. width: 100,
  166. search: true,
  167. searchOrder:1,
  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: "createTime",
  180. searchProp:"createTimeList",
  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. label: "更新人",
  190. prop: "updateUserName",
  191. searchProp:"updateUser",
  192. overHidden: true,
  193. width: 100,
  194. search: true,
  195. filterable: true,
  196. remote: true,
  197. type: "select",
  198. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  199. props: {
  200. label: "account",
  201. value: "id",
  202. res: 'data.records'
  203. }
  204. }, {
  205. label: "更新日期",
  206. prop: "updateTime",
  207. searchProp:"updateTimeList",
  208. type: "date",
  209. overHidden: true,
  210. width: 200,
  211. searchRange: true,
  212. searchDefaultTime: ["00:00:00", "23:59:59"],
  213. format: "yyyy-MM-dd",
  214. valueFormat: "yyyy-MM-dd HH:mm:ss"
  215. }]
  216. }
  217. }
  218. },
  219. activated() {
  220. if (this.$route.query.check) {
  221. this.detailsOpen = false
  222. this.detailData = {
  223. id: this.$route.query.check.billId,
  224. check: this.$route.query.check,
  225. };
  226. this.form = {
  227. id:this.$route.query.check.billId
  228. }
  229. this.detailsOpen = true
  230. this.$router.$avueRouter.closeTag(window.location.hash.slice(1))
  231. }
  232. },
  233. async created() {
  234. this.option = await this.getColumnData(this.getColumnName(235), this.optionList);
  235. this.key++
  236. let i = 0;
  237. this.option.column.forEach(item => {
  238. if (item.search) i++
  239. })
  240. if (i % 3 !== 0) {
  241. const num = 3 - Number(i % 3)
  242. this.option.searchMenuSpan = num * 8;
  243. this.option.searchMenuPosition = "right";
  244. }
  245. },
  246. methods: {
  247. check(row){
  248. this.form = row
  249. this.detailsOpen = true
  250. },
  251. backToList(type) {
  252. this.form = {}
  253. this.detailsOpen = false
  254. if (type === 0){
  255. this.detailData = {}
  256. }
  257. this.onLoad(this.page,this.search)
  258. },
  259. //刷新
  260. refreshChange() {
  261. this.onLoad(this.page, this.search)
  262. },
  263. rowDel(form, index) {
  264. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  265. confirmButtonText: '确定',
  266. cancelButtonText: '取消',
  267. type: 'warning'
  268. }).then(() => {
  269. remove(form.id).then(res => {
  270. this.$message({
  271. type: 'success',
  272. message: '删除成功!'
  273. });
  274. })
  275. }).catch(() => {
  276. });
  277. },
  278. searchChange(params, done) {
  279. done();
  280. this.onLoad(this.page, params)
  281. },
  282. onLoad(page, params = {}) {
  283. params = {
  284. ...params,
  285. current: page.currentPage,
  286. size: page.pageSize,
  287. type: "BUY",
  288. ...Object.assign(params, this.search)
  289. }
  290. this.loading = true
  291. getList(params).then(res => {
  292. this.dataList = res.data.data.records
  293. this.page.total = res.data.data.total
  294. this.loading = false
  295. }).finally(() => {
  296. this.loading = false
  297. })
  298. },
  299. outExport() {
  300. let config = {params: {...this.search}}
  301. if (config.params) {
  302. for (const propName of Object.keys(config.params)) {
  303. const value = config.params[propName];
  304. if (value !== null && typeof (value) !== "undefined") {
  305. if (value instanceof Array) {
  306. for (const key of Object.keys(value)) {
  307. let params = propName + '[' + key + ']';
  308. config.params[params] = value[key]
  309. }
  310. delete config.params[propName]
  311. }
  312. }
  313. }
  314. }
  315. const routeData = this.$router.resolve({
  316. path: '/api/blade-box-tube/tradingBox/exportTradingBoxOut', //跳转目标窗口的地址
  317. query: {
  318. ...config.params, //括号内是要传递给新窗口的参数
  319. type:"BUY"
  320. }
  321. })
  322. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  323. },
  324. //自定义列保存
  325. async saveColumnTwo(ref, option, optionBack, code) {
  326. /**
  327. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  328. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  329. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  330. */
  331. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  332. if (inSave) {
  333. this.$message.success("保存成功");
  334. //关闭窗口
  335. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  336. }
  337. },
  338. //自定义列重置
  339. async resetColumnTwo(ref, option, optionBack, code) {
  340. this[option] = this[optionBack];
  341. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  342. if (inSave) {
  343. this.$message.success("重置成功");
  344. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  345. }
  346. }
  347. }
  348. }
  349. </script>
  350. <style scoped>
  351. </style>