index.vue 9.7 KB

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