index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  5. v-model="form" id="out-table" :header-cell-class-name="headerClassName" ref="crud" @row-del="rowDel"
  6. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  8. @resetColumn="resetColumn('crud', 'option', 'optionBack', 504)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 504)" @on-load="onLoad">
  10. <template slot="menuLeft">
  11. <el-button type="primary" size="small" icon="el-icon-plus" @click="addButton">创建单据
  12. </el-button>
  13. <el-button type="success" size="small" :disabled="selectionList.length != 1" @click="copyButton">复制单据
  14. </el-button>
  15. <el-button type="warning" size="small" disabled @click="outExport">导 出
  16. </el-button>
  17. </template>
  18. <template slot="menu" slot-scope="{ row, index }">
  19. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  20. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)"
  21. :disabled="row.status > 0">删 除</el-button>
  22. </template>
  23. <template slot="sysNo" slot-scope="{ row }">
  24. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.sysNo }}</span>
  25. </template>
  26. </avue-crud>
  27. </basic-container>
  28. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  29. </div>
  30. </template>
  31. <script>
  32. import { getList, remove } from "@/api/iosBasicData/businessCenter/customerLetter.js";
  33. import { getWorkDicts } from "@/api/system/dictbiz";
  34. import detailsPage from "./detailsPage";
  35. import { getToken } from "@/util/auth";
  36. import _ from "lodash";
  37. export default {
  38. data() {
  39. return {
  40. isShow: true,
  41. form: {},
  42. query: {},
  43. loading: false,
  44. page: {
  45. pageSize: 10,
  46. currentPage: 1,
  47. total: 0
  48. },
  49. selectionList: [],
  50. option: {},
  51. optionBack: {
  52. height: 'auto',
  53. calcHeight: 30,
  54. menuWidth: 140,
  55. tip: false,
  56. searchShow: true,
  57. searchMenuSpan: 18,
  58. border: true,
  59. index: true,
  60. addBtn: false,
  61. viewBtn: false,
  62. editBtn: false,
  63. delBtn: false,
  64. selection: true,
  65. searchIcon: true,
  66. align: 'center',
  67. searchIndex: 3,
  68. column: [
  69. {
  70. label: "所属公司",
  71. prop: "branchName",
  72. overHidden: true,
  73. search: true,
  74. type: "select",
  75. filterable: true,
  76. dicUrl: "/api/blade-system/dept/lazy-list",
  77. props: {
  78. label: "deptName",
  79. value: "deptName",
  80. },
  81. },
  82. {
  83. label: "年",
  84. prop: "year",
  85. overHidden: true,
  86. search: true,
  87. type: "year",
  88. format: "yyyy",
  89. valueFormat: "yyyy",
  90. },
  91. {
  92. label: "WEEK",
  93. prop: "week",
  94. overHidden: true,
  95. search: true,
  96. },
  97. {
  98. label: "制单人",
  99. prop: "createUserName",
  100. overHidden: true,
  101. }, {
  102. label: "制单日期",
  103. prop: "createTime",
  104. type: "date",
  105. overHidden: true,
  106. format: "yyyy-MM-dd",
  107. valueFormat: "yyyy-MM-dd HH:mm:ss"
  108. }, {
  109. label: "修改人",
  110. prop: "updateUserName",
  111. overHidden: true,
  112. }, {
  113. label: "修改日期",
  114. prop: "updateTime",
  115. type: "date",
  116. overHidden: true,
  117. format: "yyyy-MM-dd",
  118. valueFormat: "yyyy-MM-dd HH:mm:ss"
  119. },
  120. {
  121. label: "开始日期",
  122. prop: "startDate",
  123. width: "100",
  124. overHidden: true,
  125. search: true,
  126. type: "date",
  127. format: "yyyy-MM-dd",
  128. valueFormat: "yyyy-MM-dd 00:00:00",
  129. },
  130. {
  131. label: "结束日期",
  132. prop: "endDate",
  133. width: "100",
  134. overHidden: true,
  135. search: true,
  136. type: "date",
  137. format: "yyyy-MM-dd",
  138. valueFormat: "yyyy-MM-dd 23:59:59",
  139. },
  140. ]
  141. },
  142. data: [],
  143. };
  144. },
  145. components: {
  146. detailsPage
  147. },
  148. async created() {
  149. this.option = await this.getColumnData(this.getColumnName(504), this.optionBack);
  150. },
  151. activated() {
  152. setTimeout(() => {
  153. }, 100);
  154. },
  155. methods: {
  156. addButton() {
  157. this.isShow = false
  158. },
  159. copyButton() {
  160. this.isShow = false
  161. this.detailData = {
  162. copyId: this.selectionList[0].id
  163. };
  164. },
  165. rowEdit(row) {
  166. this.detailData = {
  167. id: row.id
  168. };
  169. this.isShow = false
  170. },
  171. // 删除
  172. rowDel(row, index) {
  173. if (row.item == 1) {
  174. return this.$message.error("存在明细不允许删除");
  175. }
  176. this.$confirm("确定将选择数据删除?", {
  177. confirmButtonText: "确定",
  178. cancelButtonText: "取消",
  179. type: "warning"
  180. }).then(() => {
  181. remove({ ids: row.id }).then(res => {
  182. this.onLoad(this.page, this.query);
  183. this.$message.success("成功删除");
  184. })
  185. })
  186. },
  187. searchReset() {
  188. this.query = this.$options.data().query;
  189. this.onLoad(this.page);
  190. },
  191. // 搜索按钮点击
  192. searchChange(params, done) {
  193. this.page.currentPage = 1;
  194. this.onLoad(this.page, this.query);
  195. done();
  196. },
  197. selectionChange(list) {
  198. this.selectionList = list;
  199. },
  200. currentChange(currentPage) {
  201. this.page.currentPage = currentPage;
  202. },
  203. sizeChange(pageSize) {
  204. this.page.pageSize = pageSize;
  205. },
  206. refreshChange() {
  207. this.onLoad(this.page, this.query);
  208. },
  209. onLoad(page, params = {}) {
  210. let obj = {}
  211. obj = {
  212. ...Object.assign(params, this.query),
  213. }
  214. this.loading = true;
  215. getList(page.currentPage, page.pageSize, obj).then(res => {
  216. this.data = res.data.data.records;
  217. this.page.total = res.data.data.total;
  218. this.$nextTick(() => {
  219. this.$refs.crud.doLayout();
  220. this.$refs.crud.dicInit();
  221. });
  222. }).finally(() => {
  223. this.loading = false;
  224. })
  225. },
  226. // 详情的返回列表
  227. goBack() {
  228. // 初始化数据
  229. if (JSON.stringify(this.$route.query) != "{}") {
  230. this.$router.$avueRouter.closeTag();
  231. this.$router.push({
  232. path: "/iosBasicData/boxPlan/index"
  233. });
  234. }
  235. this.detailData = {}
  236. this.isShow = true;
  237. this.onLoad(this.page, this.query);
  238. },
  239. outExport() {
  240. let config = { params: { ...this.query } }
  241. if (config.params) {
  242. for (const propName of Object.keys(config.params)) {
  243. const value = config.params[propName];
  244. if (value !== null && typeof (value) !== "undefined") {
  245. if (value instanceof Array) {
  246. for (const key of Object.keys(value)) {
  247. let params = propName + '[' + key + ']';
  248. config.params[params] = value[key]
  249. }
  250. delete config.params[propName]
  251. }
  252. }
  253. }
  254. }
  255. const routeData = this.$router.resolve({
  256. path: '/api/blade-los/routecost/exportRouteCost', //跳转目标窗口的地址
  257. query: {
  258. ...config.params, //括号内是要传递给新窗口的参数
  259. identification: this.url
  260. }
  261. })
  262. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  263. },
  264. //自定义列保存
  265. async saveColumn(ref, option, optionBack, code) {
  266. /**
  267. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  268. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  269. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  270. */
  271. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  272. if (inSave) {
  273. this.$message.success("保存成功");
  274. //关闭窗口
  275. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  276. this.selectionList = []
  277. this.searchReset()
  278. }
  279. },
  280. //自定义列重置
  281. async resetColumn(ref, option, optionBack, code) {
  282. this[option] = this[optionBack];
  283. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  284. if (inSave) {
  285. this.$message.success("重置成功");
  286. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  287. this.selectionList = []
  288. this.searchReset()
  289. }
  290. },
  291. // 更改表格颜色
  292. headerClassName(tab) {
  293. //颜色间隔
  294. let back = ""
  295. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  296. if (tab.columnIndex % 2 === 0) {
  297. back = "back-one"
  298. } else if (tab.columnIndex % 2 === 1) {
  299. back = "back-two"
  300. }
  301. }
  302. return back;
  303. },
  304. }
  305. }
  306. </script>
  307. <style lang="scss" scoped>
  308. ::v-deep #out-table .back-one {
  309. background: #ecf5ff !important;
  310. text-align: center;
  311. }
  312. ::v-deep #out-table .back-two {
  313. background: #ecf5ff !important;
  314. text-align: center;
  315. }
  316. .pointerClick {
  317. cursor: pointer;
  318. color: #1e9fff;
  319. }
  320. ::v-deep .el-col-md-8 {
  321. width: 24.33333%;
  322. }
  323. </style>