index.vue 12 KB

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