index.vue 11 KB

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