index.vue 8.5 KB

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