index.vue 12 KB

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