index.vue 11 KB

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