index.vue 12 KB

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