index.vue 11 KB

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