index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div>
  3. <basic-container v-if="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. :cell-style="cellStyle"
  19. :summary-method="summaryMethod"
  20. @selection-change="selectionChange"
  21. >
  22. <template slot-scope="{ row }" slot="createUser">
  23. <span>{{ row.createUserName }}</span>
  24. </template>
  25. <template slot="portOfLoadSearch">
  26. <port-info v-model="search.portOfLoad" />
  27. </template>
  28. <template slot="portOfDestinationSearch">
  29. <port-info v-model="search.portOfDestination" />
  30. </template>
  31. <template slot="businesDateSearch">
  32. <el-date-picker
  33. v-model="search.businesDate"
  34. type="daterange"
  35. start-placeholder="开始日期"
  36. end-placeholder="结束日期"
  37. format="yyyy-MM-dd"
  38. value-format="yyyy-MM-dd HH:mm:ss"
  39. :default-time="['00:00:00', '23:59:59']"
  40. >
  41. </el-date-picker>
  42. </template>
  43. <template slot="dateValiditySearch">
  44. <el-date-picker
  45. v-model="search.dateValidity"
  46. type="daterange"
  47. start-placeholder="开始日期"
  48. end-placeholder="结束日期"
  49. format="yyyy-MM-dd"
  50. value-format="yyyy-MM-dd HH:mm:ss"
  51. :default-time="['00:00:00', '23:59:59']"
  52. >
  53. </el-date-picker>
  54. </template>
  55. <template slot="createTimeSearch">
  56. <el-date-picker
  57. v-model="search.createTime"
  58. type="daterange"
  59. start-placeholder="开始日期"
  60. end-placeholder="结束日期"
  61. format="yyyy-MM-dd"
  62. value-format="yyyy-MM-dd HH:mm:ss"
  63. :default-time="['00:00:00', '23:59:59']"
  64. >
  65. </el-date-picker>
  66. </template>
  67. <template slot="menuLeft">
  68. <el-button
  69. type="primary"
  70. icon="el-icon-plus"
  71. size="small"
  72. @click.stop="newAdd()"
  73. >新单</el-button
  74. >
  75. <el-button type="success" size="small" disabled>复制新单</el-button>
  76. <el-button type="info" size="small">报表</el-button>
  77. </template>
  78. <template slot="corpIdSearch">
  79. <select-component
  80. v-model="search.corpId"
  81. :configuration="configuration"
  82. ></select-component>
  83. </template>
  84. <template slot-scope="scope" slot="corpId">
  85. {{ scope.row.corpsName }}
  86. </template>
  87. <template slot-scope="scope" slot="grossProfitRate">
  88. {{ scope.row.grossProfitRate ? scope.row.grossProfitRate : 0 }}%
  89. </template>
  90. <template slot-scope="scope" slot="menu">
  91. <el-button
  92. type="text"
  93. icon="el-icon-edit"
  94. size="small"
  95. @click.stop="editOpen(scope.row, 2)"
  96. >编辑
  97. </el-button>
  98. <el-button
  99. type="text"
  100. icon="el-icon-delete"
  101. size="small"
  102. @click.stop="rowDel(scope.row, scope.index)"
  103. >删除
  104. </el-button>
  105. </template>
  106. </avue-crud>
  107. </basic-container>
  108. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  109. </div>
  110. </template>
  111. <script>
  112. import option from "./config/mainList.json";
  113. import { getList, remove, gainUser } from "@/api/basicData/customerInquiry";
  114. import detailPage from "./detailsPage.vue";
  115. import { defaultDate } from "@/util/date";
  116. import { micrometerFormat } from "@/util/validate";
  117. import _ from "lodash";
  118. export default {
  119. name: "customerInformation",
  120. data() {
  121. return {
  122. configuration: {
  123. multipleChoices: false,
  124. multiple: false,
  125. collapseTags: false,
  126. placeholder: "请点击右边按钮选择",
  127. dicData: [],
  128. clearable: true
  129. },
  130. search: {
  131. businesDate: defaultDate()
  132. },
  133. form: {},
  134. option: {},
  135. parentId: 0,
  136. dataList: [],
  137. page: {
  138. pageSize: 10,
  139. currentPage: 1,
  140. total: 0,
  141. pageSizes:[10,50,100,200,300,400,500]
  142. },
  143. show: true,
  144. detailData: {},
  145. loading: false,
  146. selectionList:[]
  147. };
  148. },
  149. components: { detailPage },
  150. async created() {
  151. /**
  152. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  153. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  154. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  155. */
  156. this.option = await this.getColumnData(this.getColumnName(0), option);
  157. this.getWorkDicts("order_status").then(res => {
  158. this.findObject(this.option.column, "orderStatus").dicData =
  159. res.data.data;
  160. });
  161. gainUser().then(res => {
  162. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  163. });
  164. },
  165. methods: {
  166. cellStyle() {
  167. return "padding:0;height:40px;";
  168. },
  169. //删除列表后面的删除按钮触发触发(row, index, done)
  170. rowDel(row, index, done) {
  171. this.$confirm("确定删除数据?", {
  172. confirmButtonText: "确定",
  173. cancelButtonText: "取消",
  174. type: "warning"
  175. }).then(() => {
  176. remove(row.id).then(res => {
  177. if (res.data.code == 200) {
  178. this.$message({
  179. type: "success",
  180. message: "删除成功!"
  181. });
  182. this.onLoad(this.page, this.search);
  183. }
  184. });
  185. });
  186. },
  187. selectionChange(list){
  188. this.selectionList=list
  189. },
  190. //查看跳转页面
  191. beforeOpenPage(row, status) {
  192. this.detailData = {
  193. id: row.id,
  194. status: status
  195. };
  196. this.show = false;
  197. },
  198. editOpen(row, status) {
  199. this.detailData = {
  200. id: row.id,
  201. status: status
  202. };
  203. this.show = false;
  204. },
  205. //点击搜索按钮触发
  206. searchChange(params, done) {
  207. if (params.businesDate) {
  208. params.orderStartDate = params.businesDate[0];
  209. params.orderEndDate = params.businesDate[1];
  210. }
  211. if (params.dateValidity) {
  212. params.dateValidityStart = params.dateValidity[0];
  213. params.dateValidityEnd = params.dateValidity[1];
  214. }
  215. if (params.createTime) {
  216. params.createTimeStart = params.createTime[0];
  217. params.createTimeEnd = params.createTime[1];
  218. }
  219. delete params.businesDate;
  220. delete params.dateValidity;
  221. delete params.createTime;
  222. this.page.currentPage = 1;
  223. this.onLoad(this.page, params);
  224. done();
  225. },
  226. currentChange(val) {
  227. this.page.currentPage = val;
  228. },
  229. sizeChange(val) {
  230. this.page.currentPage = 1;
  231. this.page.pageSize = val;
  232. },
  233. onLoad(page, params) {
  234. if (this.search.businesDate && this.search.businesDate.length > 0) {
  235. params = {
  236. ...params,
  237. orderStartDate: this.search.businesDate[0],
  238. orderEndDate: this.search.businesDate[1]
  239. };
  240. delete params.businesDate;
  241. }
  242. this.loading = true;
  243. getList(page.currentPage, page.pageSize, params)
  244. .then(res => {
  245. this.dataList = res.data.data.records ? res.data.data.records : [];
  246. this.page.total = res.data.data.total;
  247. if (this.page.total) {
  248. this.option.height = window.innerHeight - 350;
  249. }
  250. })
  251. .finally(() => {
  252. this.loading = false;
  253. });
  254. },
  255. summaryMethod({ columns, data }) {
  256. const sums = [];
  257. if (columns.length > 0) {
  258. columns.forEach((item, index) => {
  259. sums[0] = "合计";
  260. if (
  261. item.property == "orderQuantity" ||
  262. item.property == "amount" ||
  263. item.property == "purchaseAmount"
  264. ) {
  265. let qtySum = 0;
  266. let instoreSum = 0;
  267. let totalSum = 0;
  268. data.forEach(e => {
  269. qtySum = _.add(qtySum, Number(e.orderQuantity));
  270. instoreSum = _.add(instoreSum, Number(e.amount));
  271. totalSum = _.add(totalSum, Number(e.purchaseAmount));
  272. });
  273. //数量总计
  274. if (item.property == "orderQuantity") {
  275. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  276. }
  277. //入库金额总计
  278. if (item.property == "amount") {
  279. sums[index] = micrometerFormat(instoreSum);
  280. }
  281. //金额总计
  282. if (item.property == "purchaseAmount") {
  283. sums[index] = micrometerFormat(totalSum);
  284. }
  285. }
  286. });
  287. }
  288. return sums;
  289. },
  290. refreshChange() {
  291. this.onLoad(this.page, this.search);
  292. },
  293. newAdd() {
  294. this.show = false;
  295. },
  296. goBack() {
  297. this.detailData = this.$options.data().detailData;
  298. this.show = true;
  299. },
  300. async saveColumn() {
  301. /**
  302. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  303. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  304. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  305. */
  306. const inSave = await this.saveColumnData(
  307. this.getColumnName(0),
  308. this.option
  309. );
  310. if (inSave) {
  311. this.$message.success("保存成功");
  312. //关闭窗口
  313. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  314. }
  315. }
  316. },
  317. watch: {
  318. option: function() {
  319. this.search.businesDate = defaultDate();
  320. }
  321. }
  322. };
  323. </script>
  324. <style scoped>
  325. ::v-deep .select-component {
  326. display: flex;
  327. }
  328. .page-crad ::v-deep .basic-container__card {
  329. height: 94.2vh;
  330. }
  331. </style>