index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. let _this = this;
  162. this.option.column.forEach(e => {
  163. if (e.prop == "exchangeRate") {
  164. e.formatter = function(row) {
  165. return _this.textFormat(
  166. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  167. "0.00%"
  168. );
  169. };
  170. }
  171. if (e.prop == "creditAmount") {
  172. e.formatter = function(row) {
  173. return _this.textFormat(
  174. Number(row.creditAmount ? row.creditAmount : 0),
  175. "#,##0.00"
  176. );
  177. };
  178. }
  179. });
  180. gainUser().then(res => {
  181. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  182. });
  183. },
  184. methods: {
  185. cellStyle() {
  186. return "padding:0;height:40px;";
  187. },
  188. //删除列表后面的删除按钮触发触发(row, index, done)
  189. rowDel(row, index, done) {
  190. this.$confirm("确定删除数据?", {
  191. confirmButtonText: "确定",
  192. cancelButtonText: "取消",
  193. type: "warning"
  194. }).then(() => {
  195. remove(row.id).then(res => {
  196. if (res.data.code == 200) {
  197. this.$message({
  198. type: "success",
  199. message: "删除成功!"
  200. });
  201. this.onLoad(this.page, this.search);
  202. }
  203. });
  204. });
  205. },
  206. selectionChange(list){
  207. this.selectionList=list
  208. },
  209. //查看跳转页面
  210. beforeOpenPage(row, status) {
  211. this.detailData = {
  212. id: row.id,
  213. status: status
  214. };
  215. this.show = false;
  216. },
  217. editOpen(row, status) {
  218. this.detailData = {
  219. id: row.id,
  220. status: status
  221. };
  222. this.show = false;
  223. },
  224. //点击搜索按钮触发
  225. searchChange(params, done) {
  226. if (params.businesDate) {
  227. params.orderStartDate = params.businesDate[0];
  228. params.orderEndDate = params.businesDate[1];
  229. }
  230. if (params.dateValidity) {
  231. params.dateValidityStart = params.dateValidity[0];
  232. params.dateValidityEnd = params.dateValidity[1];
  233. }
  234. if (params.createTime) {
  235. params.createTimeStart = params.createTime[0];
  236. params.createTimeEnd = params.createTime[1];
  237. }
  238. delete params.businesDate;
  239. delete params.dateValidity;
  240. delete params.createTime;
  241. this.page.currentPage = 1;
  242. this.onLoad(this.page, params);
  243. done();
  244. },
  245. currentChange(val) {
  246. this.page.currentPage = val;
  247. },
  248. sizeChange(val) {
  249. this.page.currentPage = 1;
  250. this.page.pageSize = val;
  251. },
  252. onLoad(page, params) {
  253. if (this.search.businesDate && this.search.businesDate.length > 0) {
  254. params = {
  255. ...params,
  256. orderStartDate: this.search.businesDate[0],
  257. orderEndDate: this.search.businesDate[1]
  258. };
  259. delete params.businesDate;
  260. }
  261. this.loading = true;
  262. getList(page.currentPage, page.pageSize, params)
  263. .then(res => {
  264. this.dataList = res.data.data.records ? res.data.data.records : [];
  265. this.page.total = res.data.data.total;
  266. if (this.page.total) {
  267. this.option.height = window.innerHeight - 350;
  268. }
  269. })
  270. .finally(() => {
  271. this.loading = false;
  272. });
  273. },
  274. summaryMethod({ columns, data }) {
  275. const sums = [];
  276. if (columns.length > 0) {
  277. columns.forEach((item, index) => {
  278. sums[0] = "合计";
  279. if (
  280. item.property == "orderQuantity" ||
  281. item.property == "amount" ||
  282. item.property == "purchaseAmount"
  283. ) {
  284. let qtySum = 0;
  285. let instoreSum = 0;
  286. let totalSum = 0;
  287. data.forEach(e => {
  288. qtySum = _.add(qtySum, Number(e.orderQuantity));
  289. instoreSum = _.add(instoreSum, Number(e.amount));
  290. totalSum = _.add(totalSum, Number(e.purchaseAmount));
  291. });
  292. //数量总计
  293. if (item.property == "orderQuantity") {
  294. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  295. }
  296. //入库金额总计
  297. if (item.property == "amount") {
  298. sums[index] = micrometerFormat(instoreSum);
  299. }
  300. //金额总计
  301. if (item.property == "purchaseAmount") {
  302. sums[index] = micrometerFormat(totalSum);
  303. }
  304. }
  305. });
  306. }
  307. return sums;
  308. },
  309. refreshChange() {
  310. this.onLoad(this.page, this.search);
  311. },
  312. newAdd() {
  313. this.show = false;
  314. },
  315. goBack() {
  316. this.detailData = this.$options.data().detailData;
  317. this.show = true;
  318. },
  319. async saveColumn() {
  320. /**
  321. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  322. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  323. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  324. */
  325. const inSave = await this.saveColumnData(
  326. this.getColumnName(0),
  327. this.option
  328. );
  329. if (inSave) {
  330. this.$message.success("保存成功");
  331. //关闭窗口
  332. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  333. }
  334. }
  335. },
  336. watch: {
  337. option: function() {
  338. this.search.businesDate = defaultDate();
  339. }
  340. }
  341. };
  342. </script>
  343. <style scoped>
  344. ::v-deep .select-component {
  345. display: flex;
  346. }
  347. .page-crad ::v-deep .basic-container__card {
  348. height: 94.2vh;
  349. }
  350. </style>