index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. export default {
  73. name: "customerInformation",
  74. props: {
  75. detailData: {
  76. type: Object
  77. }
  78. },
  79. components: {
  80. detailPage
  81. },
  82. data() {
  83. return {
  84. configuration: {
  85. multipleChoices: false,
  86. multiple: false,
  87. collapseTags: false,
  88. placeholder: "请点击右边按钮选择",
  89. dicData: [],
  90. },
  91. search: {},
  92. form: {},
  93. option: {},
  94. parentId: 0,
  95. dataList: [],
  96. page: {
  97. pageSize: 10,
  98. pagerCount: 5,
  99. total: 0,
  100. },
  101. // 非单个禁用
  102. single: true,
  103. // 非多个禁用
  104. multiple: true,
  105. selection: [],
  106. isShow: true,
  107. detailData: {},
  108. }
  109. },
  110. async created() {
  111. // this.option = option
  112. this.option = await this.getColumnData(this.getColumnName(17), option);
  113. let i = 0;
  114. this.option.column.forEach(item => {
  115. if (item.search) i++
  116. })
  117. if (i % 4 !== 0){
  118. const num = 4 - Number(i % 4)
  119. this.option.searchMenuSpan = num * 6;
  120. this.option.searchMenuPosition = "right";
  121. }
  122. this.option.column.forEach(item => {
  123. if (item.pickerOptions) {
  124. item.pickerOptions = {
  125. shortcuts: [{
  126. text: '最近一周',
  127. onClick(picker) {
  128. const end = new Date();
  129. const start = new Date();
  130. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  131. picker.$emit('pick', [start, end]);
  132. }
  133. }, {
  134. text: '最近一个月',
  135. onClick(picker) {
  136. const end = new Date();
  137. const start = new Date();
  138. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  139. picker.$emit('pick', [start, end]);
  140. }
  141. }, {
  142. text: '最近三个月',
  143. onClick(picker) {
  144. const end = new Date();
  145. const start = new Date();
  146. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  147. picker.$emit('pick', [start, end]);
  148. }
  149. }]
  150. }
  151. }
  152. })
  153. },
  154. methods: {
  155. //删除列表后面的删除按钮触发触发(row, index, done)
  156. rowDel(row, index, done) {
  157. this.$confirm("确定将选择数据删除?", {
  158. confirmButtonText: "确定",
  159. cancelButtonText: "取消",
  160. type: "warning"
  161. }).then(() => {
  162. return deleteDetails(row.id);
  163. }).then(() => {
  164. this.$message({
  165. type: "success",
  166. message: "操作成功!"
  167. });
  168. this.page.currentPage = 1;
  169. this.onLoad(this.page, {parentId: 0});
  170. });
  171. },
  172. //查询全部
  173. initData() {
  174. customerList().then(res => {
  175. console.log(this.form);
  176. const column = this.findObject(this.option.column, "parentId");
  177. column.dicData = res.data.data.records;
  178. });
  179. },
  180. //新增子项触发
  181. handleAdd(row) {
  182. this.parentId = row.id;
  183. const column = this.findObject(this.option.column, "parentId");
  184. column.value = row.id;
  185. column.addDisabled = true;
  186. this.$refs.crud.rowAdd();
  187. },
  188. //查看跳转页面
  189. beforeOpenPage(row, index) {
  190. this.detailData = {
  191. id: row.id,
  192. };
  193. this.isShow = false;
  194. },
  195. //新增跳转页面
  196. beforeOpen(row, index) {
  197. this.detailData = {
  198. id: row.id,
  199. };
  200. this.isShow = false;
  201. },
  202. editOpen(row, index) {
  203. this.detailData = {
  204. id: row.id,
  205. };
  206. this.isShow = false;
  207. },
  208. // 复制新单
  209. copyOrder() {
  210. const id = this.selection[0].id;
  211. this.detailData = {
  212. copyId: id,
  213. };
  214. this.isShow = false;
  215. },
  216. //点击新增时触发
  217. beforeClose(done) {
  218. this.parentId = "";
  219. const column = this.findObject(this.option.column, "parentId");
  220. column.value = "";
  221. column.addDisabled = false;
  222. done();
  223. },
  224. //点击搜索按钮触发
  225. searchChange(params, done) {
  226. console.log(params)
  227. this.page.currentPage = 1;
  228. this.onLoad(this.page, params);
  229. done()
  230. },
  231. searchReset() {
  232. console.log('1')
  233. },
  234. selectionChange(list) {
  235. this.selection = list;
  236. this.single = list.length !== 1;
  237. },
  238. currentChange() {
  239. console.log('1')
  240. },
  241. sizeChange() {
  242. console.log('1')
  243. },
  244. refreshChange() {
  245. console.log('1')
  246. },
  247. onLoad(page, params) {
  248. if (params) {
  249. if (params.requiredArrivalDate) {
  250. this.$set(params, 'requiredArrivalStartDate', params.requiredArrivalDate[0]+ " " + "00:00:00")
  251. this.$set(params, 'requiredArrivalEndDate', params.requiredArrivalDate[1]+ " " + "23:59:59")
  252. this.$delete(params,'requiredArrivalDate')
  253. }
  254. }
  255. let queryParams = Object.assign({tradeType: 'GN'}, params, {
  256. size: page.pageSize,
  257. current: page.currentPage,
  258. // billType:'CG',
  259. // corpsTypeId: this.treeDeptId
  260. })
  261. customerList(queryParams).then(res => {
  262. this.dataList = res.data.data.records
  263. this.page.total = res.data.data.total
  264. })
  265. },
  266. //树桩列点击展开触发
  267. treeLoad(tree, treeNode, resolve) {
  268. const parentId = tree.id;
  269. customerList({parentId: parentId}).then(res => {
  270. resolve(res.data.data.records);
  271. });
  272. },
  273. goBack() {
  274. this.detailData=this.$options.data().detailData
  275. this.isShow = true;
  276. },
  277. //列保存触发
  278. async saveColumn() {
  279. /**
  280. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  281. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  282. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  283. */
  284. const inSave = await this.saveColumnData(
  285. this.getColumnName(17),
  286. this.option
  287. );
  288. if (inSave) {
  289. this.$message.success("保存成功");
  290. //关闭窗口
  291. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  292. }
  293. },
  294. }
  295. }
  296. </script>
  297. <style scoped>
  298. </style>