index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. },
  130. // 非单个禁用
  131. single: true,
  132. // 非多个禁用
  133. multiple: true,
  134. selection: [],
  135. isShow: true,
  136. detailData: {},
  137. }
  138. },
  139. async created() {
  140. this.search.businessDate = defaultDate(1)
  141. this.option = option
  142. // this.option = await this.getColumnData(this.getColumnName(20), option);
  143. let i = 0;
  144. this.option.column.forEach(item => {
  145. if (item.search) i++
  146. })
  147. if (i % 3 !== 0){
  148. const num = 3 - Number(i % 3)
  149. this.option.searchMenuSpan = num * 8;
  150. this.option.searchMenuPosition = "right";
  151. }
  152. this.option.column.forEach(item => {
  153. if (item.pickerOptions) {
  154. item.pickerOptions = {
  155. shortcuts: [{
  156. text: '最近一周',
  157. onClick(picker) {
  158. const end = new Date();
  159. const start = new Date();
  160. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  161. picker.$emit('pick', [start, end]);
  162. }
  163. }, {
  164. text: '最近一个月',
  165. onClick(picker) {
  166. const end = new Date();
  167. const start = new Date();
  168. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  169. picker.$emit('pick', [start, end]);
  170. }
  171. }, {
  172. text: '最近三个月',
  173. onClick(picker) {
  174. const end = new Date();
  175. const start = new Date();
  176. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  177. picker.$emit('pick', [start, end]);
  178. }
  179. }]
  180. }
  181. }
  182. })
  183. },
  184. activated() {
  185. setTimeout(() => {
  186. if (this.$route.query.form) {
  187. this.detailData = {
  188. form: this.$route.query.form,
  189. };
  190. this.$store.commit("IN_IN_DETAIL");
  191. this.isShow = false;
  192. }
  193. }, 100);
  194. },
  195. methods: {
  196. //删除列表后面的删除按钮触发触发(row, index, done)
  197. rowDel(row, index, done) {
  198. this.$confirm("确定将选择数据删除?", {
  199. confirmButtonText: "确定",
  200. cancelButtonText: "取消",
  201. type: "warning"
  202. }).then(() => {
  203. return deleteDetails(row.id);
  204. }).then(() => {
  205. this.$message({
  206. type: "success",
  207. message: "操作成功!"
  208. });
  209. this.page.currentPage = 1;
  210. this.onLoad(this.page, {parentId: 0});
  211. });
  212. },
  213. //修改时的修改按钮点击触发
  214. rowUpdate(row, index, done, loading) {
  215. typeSave(row).then(() => {
  216. this.$message({
  217. type: "success",
  218. message: "操作成功!"
  219. });
  220. // 数据回调进行刷新
  221. done(row);
  222. }, error => {
  223. window.console.log(error);
  224. loading();
  225. });
  226. },
  227. //新增修改时保存触发
  228. rowSave(row, done, loading) {
  229. typeSave(row).then(res => {
  230. console.log(res)
  231. done()
  232. })
  233. },
  234. //查询全部
  235. initData() {
  236. customerList().then(res => {
  237. console.log(this.form);
  238. const column = this.findObject(this.option.column, "parentId");
  239. column.dicData = res.data.data.records;
  240. });
  241. },
  242. //新增子项触发
  243. handleAdd(row) {
  244. this.parentId = row.id;
  245. const column = this.findObject(this.option.column, "parentId");
  246. column.value = row.id;
  247. column.addDisabled = true;
  248. this.$refs.crud.rowAdd();
  249. },
  250. //查看跳转页面
  251. beforeOpenPage(row, index) {
  252. // /deliveryNotice_detailsPageEdit
  253. this.detailData = {
  254. id: row.id,
  255. seeDisabled: true,
  256. };
  257. this.isShow = false;
  258. this.$store.commit("IN_IN_DETAIL");
  259. },
  260. //新增跳转页面
  261. beforeOpen(row, index) {
  262. this.detailData = {
  263. id: row.id,
  264. };
  265. this.isShow = false;
  266. this.$store.commit("IN_IN_DETAIL");
  267. },
  268. editOpen(row, index) {
  269. this.detailData = {
  270. id: row.id,
  271. };
  272. this.isShow = false;
  273. this.$store.commit("IN_IN_DETAIL");
  274. },
  275. // 复制新单
  276. copyOrder() {
  277. const id = this.selection[0].id;
  278. this.detailData = {
  279. copyId: id,
  280. };
  281. this.isShow = false;
  282. this.$store.commit("IN_IN_DETAIL");
  283. },
  284. //点击新增时触发
  285. beforeClose(done) {
  286. this.parentId = "";
  287. const column = this.findObject(this.option.column, "parentId");
  288. column.value = "";
  289. column.addDisabled = false;
  290. done();
  291. },
  292. //点击搜索按钮触发
  293. searchChange(params, done) {
  294. if (params.businessDate) {
  295. params.businessStartDate = params.businessDate[0]+ " " + "00:00:00"
  296. params.businessEndDate = params.businessDate[1]+ " " + "23:59:59"
  297. }
  298. if (params.createTime) {
  299. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  300. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  301. this.$delete(params,'createTime')
  302. }
  303. this.page.currentPage = 1;
  304. this.onLoad(this.page, params);
  305. done()
  306. },
  307. searchReset() {
  308. // this.configuration.dicData = []
  309. },
  310. selectionChange(list) {
  311. this.selection = list;
  312. this.single = list.length !== 1;
  313. },
  314. currentChange() {
  315. console.log('1')
  316. },
  317. sizeChange() {
  318. console.log('1')
  319. },
  320. refreshChange() {
  321. console.log('1')
  322. },
  323. onLoad(page, params) {
  324. if (this.search.businessDate.length > 0) {
  325. params = {
  326. ...params,
  327. businessStartDate: this.search.businessDate[0]+ " " + "00:00:00",
  328. businessEndDate: this.search.businessDate[1]+ " " + "23:59:59",
  329. }
  330. this.$delete(params,'businessDate')
  331. }
  332. let queryParams = Object.assign({}, params, {
  333. size: page.pageSize,
  334. current: page.currentPage,
  335. billType:"FH"
  336. })
  337. customerList(queryParams).then(res => {
  338. this.dataList = res.data.data.records
  339. this.page.total = res.data.data.total
  340. })
  341. },
  342. //树桩列点击展开触发
  343. treeLoad(tree, treeNode, resolve) {
  344. const parentId = tree.id;
  345. customerList({parentId: parentId}).then(res => {
  346. resolve(res.data.data.records);
  347. });
  348. },
  349. goBack() {
  350. this.detailData=this.$options.data().detailData
  351. if (this.$route.query) {
  352. this.$router.$avueRouter.closeTag();
  353. this.$router.push({
  354. path: "/businessManagement/deliveryNotice/index"
  355. });
  356. }
  357. this.isShow = true;
  358. this.$store.commit("IN_OUT_DETAIL");
  359. },
  360. //列保存触发
  361. async saveColumn() {
  362. /**
  363. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  364. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  365. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  366. */
  367. const inSave = await this.saveColumnData(
  368. this.getColumnName(20),
  369. this.option
  370. );
  371. if (inSave) {
  372. this.$message.success("保存成功");
  373. //关闭窗口
  374. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  375. }
  376. },
  377. }
  378. }
  379. </script>
  380. <style scoped>
  381. </style>