index.vue 11 KB

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