index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <div>
  3. <basic-container
  4. v-if="isShow">
  5. <avue-crud :option="option"
  6. :data="dataList"
  7. ref="crud"
  8. v-model="form"
  9. :page.sync="page"
  10. @row-del="rowDel"
  11. @row-update="rowUpdate"
  12. :before-open="beforeOpen"
  13. :before-close="beforeClose"
  14. :search.sync="search"
  15. @row-save="rowSave"
  16. @saveColumn="saveColumn"
  17. @search-change="searchChange"
  18. @search-reset="searchReset"
  19. @selection-change="selectionChange"
  20. @current-change="currentChange"
  21. @size-change="sizeChange"
  22. @refresh-change="refreshChange"
  23. @on-load="onLoad"
  24. @tree-load="treeLoad"
  25. >
  26. <template slot="corpIdSearch">
  27. <select-component
  28. v-model="search.corpId"
  29. :configuration="configuration"
  30. ></select-component>
  31. </template>
  32. <template slot-scope="scope" slot="corpId">
  33. {{ scope.row.corpsName }}
  34. </template>
  35. <template slot="menuLeft" slot-scope="{size}">
  36. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制新单</el-button>
  37. <el-button type="info" :size="size" icon="el-icon-printer">报 表</el-button>
  38. </template>
  39. <template slot-scope="scope" slot="menu">
  40. <el-button
  41. type="text"
  42. icon="el-icon-view"
  43. size="small"
  44. @click.stop="beforeOpenPage(scope.row,scope.index)"
  45. >查看
  46. </el-button>
  47. <el-button
  48. type="text"
  49. icon="el-icon-edit"
  50. size="small"
  51. @click.stop="editOpen(scope.row,scope.index)"
  52. >编辑
  53. </el-button>
  54. <el-button
  55. type="text"
  56. icon="el-icon-delete"
  57. size="small"
  58. @click.stop="rowDel(scope.row,scope.index)"
  59. >删除
  60. </el-button>
  61. </template>
  62. </avue-crud>
  63. </basic-container>
  64. <detail-page
  65. ref="detail"
  66. @goBack="goBack"
  67. :detailData="detailData"
  68. v-else
  69. ></detail-page>
  70. </div>
  71. </template>
  72. <script>
  73. import option from "./configuration/mainList.json";
  74. import {customerList, typeSave, deleteDetails} from "@/api/basicData/configuration"
  75. import detailPage from "./detailsPageEdit";
  76. import search from "../../../page/index/search";
  77. import { defaultDate } from "@/util/date";
  78. export default {
  79. name: "customerInformation",
  80. components: {
  81. detailPage
  82. },
  83. data() {
  84. return {
  85. configuration: {
  86. multipleChoices: false,
  87. multiple: false,
  88. collapseTags: false,
  89. placeholder: "请点击右边按钮选择",
  90. dicData: [],
  91. clearable: true
  92. },
  93. form: {},
  94. option: {},
  95. parentId: 0,
  96. search:{},
  97. dataList: [],
  98. page: {
  99. pageSize: 10,
  100. pagerCount: 5,
  101. total: 0,
  102. },
  103. // 非单个禁用
  104. single: true,
  105. // 非多个禁用
  106. multiple: true,
  107. selection: [],
  108. isShow: true,
  109. detailData: {},
  110. }
  111. },
  112. async created() {
  113. this.search.businesDate = defaultDate()
  114. this.option = option
  115. // this.option = await this.getColumnData(this.getColumnName(14), option);
  116. let i = 0;
  117. this.option.column.forEach(item => {
  118. if (item.search) i++
  119. })
  120. if (i % 4 !== 0){
  121. const num = 4 - Number(i % 4)
  122. this.option.searchMenuSpan = num * 6;
  123. this.option.searchMenuPosition = "right";
  124. }
  125. this.option.column.forEach(item => {
  126. if (item.pickerOptions) {
  127. item.pickerOptions = {
  128. shortcuts: [{
  129. text: '最近一周',
  130. onClick(picker) {
  131. const end = new Date();
  132. const start = new Date();
  133. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  134. picker.$emit('pick', [start, end]);
  135. }
  136. }, {
  137. text: '最近一个月',
  138. onClick(picker) {
  139. const end = new Date();
  140. const start = new Date();
  141. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  142. picker.$emit('pick', [start, end]);
  143. }
  144. }, {
  145. text: '最近三个月',
  146. onClick(picker) {
  147. const end = new Date();
  148. const start = new Date();
  149. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  150. picker.$emit('pick', [start, end]);
  151. }
  152. }]
  153. }
  154. }
  155. })
  156. },
  157. methods: {
  158. // 获取日期
  159. getDate() {},
  160. //删除列表后面的删除按钮触发触发(row, index, done)
  161. rowDel(row, index, done) {
  162. this.$confirm("确定将选择数据删除?", {
  163. confirmButtonText: "确定",
  164. cancelButtonText: "取消",
  165. type: "warning"
  166. }).then(() => {
  167. return deleteDetails(row.id);
  168. }).then(() => {
  169. this.$message({
  170. type: "success",
  171. message: "操作成功!"
  172. });
  173. this.page.currentPage = 1;
  174. this.onLoad(this.page, {parentId: 0});
  175. });
  176. },
  177. //修改时的修改按钮点击触发
  178. rowUpdate(row, index, done, loading) {
  179. typeSave(row).then(() => {
  180. this.$message({
  181. type: "success",
  182. message: "操作成功!"
  183. });
  184. // 数据回调进行刷新
  185. done(row);
  186. }, error => {
  187. window.console.log(error);
  188. loading();
  189. });
  190. },
  191. //新增修改时保存触发
  192. rowSave(row, done, loading) {
  193. typeSave(row).then(res => {
  194. console.log(res)
  195. done()
  196. })
  197. },
  198. //列保存触发
  199. async saveColumn() {
  200. /**
  201. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  202. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  203. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  204. */
  205. const inSave = await this.saveColumnData(
  206. this.getColumnName(14),
  207. this.option
  208. );
  209. if (inSave) {
  210. this.$message.success("保存成功");
  211. //关闭窗口
  212. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  213. }
  214. },
  215. //查询全部
  216. initData() {
  217. customerList().then(res => {
  218. console.log(this.form);
  219. const column = this.findObject(this.option.column, "parentId");
  220. column.dicData = res.data.data.records;
  221. });
  222. },
  223. //新增子项触发
  224. handleAdd(row) {
  225. this.parentId = row.id;
  226. const column = this.findObject(this.option.column, "parentId");
  227. column.value = row.id;
  228. column.addDisabled = true;
  229. this.$refs.crud.rowAdd();
  230. },
  231. closeDetailPage() {
  232. this.isShow = true
  233. },
  234. //查看跳转页面
  235. beforeOpenPage(row, index) {
  236. this.detailData = {
  237. id: row.id,
  238. };
  239. this.isShow = false;
  240. },
  241. //新增跳转页面
  242. beforeOpen(row, index) {
  243. this.detailData = {
  244. id: row.id,
  245. };
  246. this.isShow = false;
  247. },
  248. editOpen(row, index) {
  249. this.detailData = {
  250. id: row.id,
  251. };
  252. this.isShow = false;
  253. },
  254. // 复制新单
  255. copyOrder() {
  256. const id = this.selection[0].id;
  257. this.detailData = {
  258. copyId: id,
  259. };
  260. this.isShow = false;
  261. },
  262. //点击新增时触发
  263. beforeClose(done) {
  264. this.parentId = "";
  265. const column = this.findObject(this.option.column, "parentId");
  266. column.value = "";
  267. column.addDisabled = false;
  268. done();
  269. },
  270. //点击搜索按钮触发
  271. searchChange(params, done) {
  272. console.log(params)
  273. this.page.currentPage = 1;
  274. this.onLoad(this.page, params);
  275. done()
  276. },
  277. searchReset() {
  278. this.configuration.dicData = []
  279. },
  280. // 选择框
  281. selectionChange(list) {
  282. this.selection = list;
  283. this.single = list.length !== 1;
  284. },
  285. currentChange() {
  286. console.log('1')
  287. },
  288. sizeChange() {
  289. console.log('1')
  290. },
  291. //列表刷新触发
  292. refreshChange() {
  293. console.log(this.form)
  294. this.page.currentPage = 1;
  295. this.onLoad(this.page,this.search);
  296. },
  297. onLoad(page, params) {
  298. if (this.search.businesDate.length > 0) {
  299. console.log(this.search.businesDate)
  300. }
  301. if (params) {
  302. if (params.requiredDeliveryDate) {
  303. params.deliveryStartDate = params.requiredDeliveryDate[0]+ " " + "00:00:00"
  304. params.deliveryEndDate = params.requiredDeliveryDate[1]+ " " + "23:59:59"
  305. this.$delete(params,'requiredDeliveryDate')
  306. }
  307. if (params.requiredArrivalDate) {
  308. params.arrivalStartDate = params.requiredArrivalDate[0]+ " " + "00:00:00"
  309. params.arrivalEndDate = params.requiredArrivalDate[1]+ " " + "23:59:59"
  310. this.$delete(params,'requiredArrivalDate')
  311. }
  312. }
  313. let queryParams = Object.assign({}, params, {
  314. size: page.pageSize,
  315. current: page.currentPage,
  316. billType:'XS',
  317. corpsTypeId: this.treeDeptId
  318. })
  319. customerList(queryParams).then(res => {
  320. this.dataList = res.data.data.records
  321. this.page.total = res.data.data.total
  322. })
  323. },
  324. //树桩列点击展开触发
  325. treeLoad(tree, treeNode, resolve) {
  326. const parentId = tree.id;
  327. customerList({parentId: parentId}).then(res => {
  328. resolve(res.data.data.records);
  329. });
  330. },
  331. goBack() {
  332. this.detailData=this.$options.data().detailData
  333. this.isShow = true;
  334. },
  335. }
  336. }
  337. </script>
  338. <style scoped>
  339. </style>