index.vue 10 KB

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