index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div>
  3. <basic-container v-show="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. @resetColumn="resetColumn"
  18. :cell-style="cellStyle"
  19. :summary-method="summaryMethod"
  20. @expand-change="expandChange"
  21. @selection-change="selectionChange"
  22. @search-criteria-switch="searchCriteriaSwitch"
  23. >
  24. <template slot-scope="{ row }" slot="expand">
  25. <avue-crud
  26. :data="row.itemData"
  27. :option="itemOption"
  28. :table-loading="row.itemLoading"
  29. :cell-style="cellStyle"
  30. class="itemTable"
  31. ></avue-crud>
  32. </template>
  33. <template slot-scope="{ row }" slot="grossProfitRate">
  34. {{ row.grossProfitRate }}%
  35. </template>
  36. <template slot-scope="{ row }" slot="createUser">
  37. <span>{{ row.createUserName }}</span>
  38. </template>
  39. <template slot-scope="{ row }" slot="orderQuantity">
  40. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  41. </template>
  42. <template slot="menuLeft">
  43. <el-button
  44. type="primary"
  45. icon="el-icon-plus"
  46. size="small"
  47. @click.stop="newAdd('new')"
  48. >创建单据
  49. </el-button>
  50. <el-button
  51. type="success"
  52. size="small"
  53. @click.stop="copyDoc()"
  54. :disabled="selectionList.length != 1"
  55. >复制单据</el-button
  56. >
  57. <el-button type="info" size="small">报表打印</el-button>
  58. </template>
  59. <template slot="corpIdSearch">
  60. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  61. </template>
  62. <template slot="portOfLoadSearch">
  63. <port-info v-model="search.portOfLoad" />
  64. </template>
  65. <template slot="portOfDestinationSearch">
  66. <port-info v-model="search.portOfDestination" />
  67. </template>
  68. <template slot="businesDateSearch">
  69. <el-date-picker
  70. v-model="search.businesDate"
  71. type="daterange"
  72. start-placeholder="开始日期"
  73. end-placeholder="结束日期"
  74. format="yyyy-MM-dd"
  75. value-format="yyyy-MM-dd HH:mm:ss"
  76. :default-time="['00:00:00', '23:59:59']"
  77. >
  78. </el-date-picker>
  79. </template>
  80. <template slot="plannedDeliveryDateSearch">
  81. <el-date-picker
  82. v-model="search.plannedDeliveryDate"
  83. type="daterange"
  84. start-placeholder="开始日期"
  85. end-placeholder="结束日期"
  86. format="yyyy-MM-dd"
  87. value-format="yyyy-MM-dd HH:mm:ss"
  88. :default-time="['00:00:00', '23:59:59']"
  89. >
  90. </el-date-picker>
  91. </template>
  92. <template slot="createTimeSearch">
  93. <el-date-picker
  94. v-model="search.createTime"
  95. type="daterange"
  96. start-placeholder="开始日期"
  97. end-placeholder="结束日期"
  98. format="yyyy-MM-dd"
  99. value-format="yyyy-MM-dd HH:mm:ss"
  100. :default-time="['00:00:00', '23:59:59']"
  101. >
  102. </el-date-picker>
  103. </template>
  104. <template slot-scope="scope" slot="corpId">
  105. <span
  106. style="color: #409EFF;cursor: pointer"
  107. @click.stop="editOpen(scope.row, 1)"
  108. >{{ scope.row.corpsName }}
  109. </span>
  110. </template>
  111. <template slot-scope="scope" slot="orderNo">
  112. <span
  113. style="color: #409EFF;cursor: pointer"
  114. @click.stop="editOpen(scope.row, 1)"
  115. >{{ scope.row.orderNo }}
  116. </span>
  117. </template>
  118. <template slot-scope="scope" slot="menu">
  119. <el-button
  120. type="text"
  121. icon="el-icon-delete"
  122. size="small"
  123. @click.stop="rowDel(scope.row, scope.index)"
  124. >删除
  125. </el-button>
  126. </template>
  127. </avue-crud>
  128. </basic-container>
  129. <detail-page
  130. @goBack="goBack"
  131. @copyOrder="copyOrder"
  132. :detailData="detailData"
  133. v-if="!show"
  134. ></detail-page>
  135. </div>
  136. </template>
  137. <script>
  138. import option from "./config/mainList.json";
  139. import {
  140. getList,
  141. remove,
  142. getPorts,
  143. gainUser,
  144. getGoodsInfo
  145. } from "@/api/basicData/salesContract";
  146. import detailPage from "./detailsPage.vue";
  147. import { defaultDate } from "@/util/date";
  148. import { micrometerFormat, IntegerFormat } from "@/util/validate";
  149. import _ from "lodash";
  150. export default {
  151. name: "customerInformation",
  152. data() {
  153. return {
  154. search: {
  155. businesDate: defaultDate()
  156. },
  157. form: {},
  158. option: {},
  159. parentId: 0,
  160. dataList: [],
  161. page: {
  162. pageSize: 20,
  163. currentPage: 1,
  164. total: 0,
  165. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  166. },
  167. show: true,
  168. detailData: {},
  169. loading: false,
  170. itemOption: {
  171. align: "center",
  172. header: false,
  173. menu: false,
  174. column: [
  175. {
  176. label: "产品类别",
  177. prop: "priceCategory",
  178. width: 138,
  179. overHidden: true
  180. },
  181. {
  182. label: "产品名称",
  183. prop: "cname",
  184. width: 100,
  185. overHidden: true
  186. },
  187. {
  188. label: "产品描述",
  189. prop: "itemDescription",
  190. width: 100,
  191. overHidden: true
  192. },
  193. {
  194. label: "配件描述",
  195. prop: "partsDescribe",
  196. width: 100,
  197. overHidden: true
  198. },
  199. {
  200. label: "配件价格描述",
  201. prop: "partsPriceDescribe",
  202. width: 100,
  203. overHidden: true
  204. },
  205. {
  206. label: "数量",
  207. prop: "orderQuantity",
  208. width: 100,
  209. overHidden: true
  210. },
  211. {
  212. label: "金额",
  213. prop: "amount",
  214. width: 100,
  215. overHidden: true
  216. }
  217. ]
  218. },
  219. selectionList: []
  220. };
  221. },
  222. components: { detailPage },
  223. async created() {
  224. this.option = await this.getColumnData(this.getColumnName(4), option);
  225. getPorts().then(res => {
  226. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  227. this.findObject(this.option.column, "portOfDestination").dicData =
  228. res.data;
  229. });
  230. this.getWorkDicts("order_status").then(res => {
  231. this.findObject(this.option.column, "orderStatus").dicData =
  232. res.data.data;
  233. });
  234. gainUser().then(res => {
  235. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  236. });
  237. },
  238. filters: {
  239. IntegerFormat(num) {
  240. return IntegerFormat(num);
  241. }
  242. },
  243. activated() {
  244. if (!this.$store.getters.xsStatus && !this.show) {
  245. this.show = true;
  246. }
  247. if (this.$route.query.id) {
  248. setTimeout(() => {
  249. this.editOpen({ id: this.$route.query.id }, 1);
  250. }, 100);
  251. }
  252. },
  253. methods: {
  254. searchCriteriaSwitch(type) {
  255. if (type) {
  256. this.option.height = this.option.height - 191;
  257. } else {
  258. this.option.height = this.option.height + 191;
  259. }
  260. this.$refs.crud.getTableHeight();
  261. },
  262. cellStyle() {
  263. return "padding:0;height:40px;";
  264. },
  265. selectionChange(list) {
  266. this.selectionList = list;
  267. },
  268. expandChange(row) {
  269. if (!row.itemData) {
  270. getGoodsInfo({ id: row.id, tradeType: "CK" })
  271. .then(res => {
  272. this.dataList[row.$index].itemData = res.data.data;
  273. })
  274. .finally(() => {
  275. this.dataList[row.$index].itemLoading = false;
  276. });
  277. }
  278. },
  279. //删除列表后面的删除按钮触发触发(row, index, done)
  280. rowDel(row, index, done) {
  281. this.$confirm("确定删除数据?", {
  282. confirmButtonText: "确定",
  283. cancelButtonText: "取消",
  284. type: "warning"
  285. }).then(() => {
  286. remove(row.id).then(res => {
  287. if (res.data.code == 200) {
  288. this.$message({
  289. type: "success",
  290. message: "删除成功!"
  291. });
  292. this.onLoad(this.page, this.search);
  293. }
  294. });
  295. });
  296. },
  297. //查看跳转页面
  298. editOpen(row, status) {
  299. if (this.$route.query.id) {
  300. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  301. this.$router.push({
  302. path: "/exportTrade/salesContract/index"
  303. });
  304. }
  305. this.detailData = {
  306. id: row.id,
  307. status: status
  308. };
  309. this.show = false;
  310. this.$store.commit("IN_XS_STATUS");
  311. },
  312. //点击搜索按钮触发
  313. searchChange(params, done) {
  314. if (params.businesDate) {
  315. params.orderStartDate = params.businesDate[0];
  316. params.orderEndDate = params.businesDate[1];
  317. }
  318. if (params.plannedDeliveryDate) {
  319. params.plannedDeliveryStart = params.plannedDeliveryDate[0];
  320. params.plannedDeliveryEnd = params.plannedDeliveryDate[1];
  321. }
  322. if (params.createTime) {
  323. params.createTimeStart = params.createTime[0];
  324. params.createTimeEnd = params.createTime[1];
  325. }
  326. delete params.businesDate;
  327. delete params.plannedDeliveryDate;
  328. delete params.createTime;
  329. this.page.currentPage = 1;
  330. this.onLoad(this.page, params);
  331. done();
  332. },
  333. currentChange(val) {
  334. this.page.currentPage = val;
  335. },
  336. sizeChange(val) {
  337. this.page.currentPage = 1;
  338. this.page.pageSize = val;
  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],
  345. orderEndDate: this.search.businesDate[1]
  346. };
  347. delete params.businesDate;
  348. }
  349. this.dataList.forEach(item => {
  350. this.$refs.crud.toggleRowExpansion(item, false);
  351. });
  352. getList(page.currentPage, page.pageSize, params).then(res => {
  353. if (res.data.data.records) {
  354. res.data.data.records.forEach(e => {
  355. e.itemLoading = true;
  356. });
  357. }
  358. this.dataList = res.data.data.records ? res.data.data.records : [];
  359. this.page.total = res.data.data.total;
  360. if (this.page.total) {
  361. this.option.height = window.innerHeight - 210;
  362. }
  363. });
  364. },
  365. refreshChange() {
  366. this.onLoad(this.page, this.search);
  367. },
  368. newAdd(type) {
  369. this.detailData = {
  370. pageType: type
  371. };
  372. this.show = false;
  373. this.$store.commit("IN_XS_STATUS");
  374. },
  375. copyDoc() {
  376. this.selectionList.forEach(e => {
  377. this.detailData = {
  378. id: e.id,
  379. status: "copy"
  380. };
  381. this.show = false;
  382. this.$store.commit("IN_XS_STATUS");
  383. });
  384. },
  385. copyOrder(id) {
  386. this.show = true;
  387. this.detailData = {
  388. id: id,
  389. status: "copy"
  390. };
  391. this.$nextTick(() => {
  392. this.show = false;
  393. this.$store.commit("IN_XS_STATUS");
  394. });
  395. },
  396. goBack() {
  397. this.detailData = this.$options.data().detailData;
  398. this.show = true;
  399. this.onLoad(this.page, this.search);
  400. this.$store.commit("OUT_XS_STATUS");
  401. },
  402. summaryMethod({ columns, data }) {
  403. const sums = [];
  404. if (columns.length > 0) {
  405. columns.forEach((item, index) => {
  406. sums[0] = "合计";
  407. if (
  408. item.property == "minOrder" ||
  409. item.property == "predictOceanFreight" ||
  410. item.property == "referenceOceanFreight" ||
  411. item.property == "oceanFreight" ||
  412. item.property == "orderQuantity" ||
  413. item.property == "actualQuantity" ||
  414. item.property == "grossProfit" ||
  415. item.property == "amount" ||
  416. item.property == "purchaseAmount"
  417. ) {
  418. let qtySum = 0;
  419. let instoreSum = 0;
  420. let totalSum = 0;
  421. let oceanFreightSum = 0;
  422. let orderQuantitySum = 0;
  423. let actualQuantitySum = 0;
  424. let amountSum = 0;
  425. let purchaseAmountSum = 0;
  426. data.forEach(e => {
  427. qtySum = _.add(qtySum, Number(e.minOrder));
  428. instoreSum = _.add(instoreSum, Number(e.predictOceanFreight));
  429. totalSum = _.add(totalSum, Number(e.referenceOceanFreight));
  430. oceanFreightSum = _.add(oceanFreightSum, Number(e.oceanFreight));
  431. orderQuantitySum = _.add(
  432. orderQuantitySum,
  433. Number(e.orderQuantity)
  434. );
  435. actualQuantitySum = _.add(
  436. actualQuantitySum,
  437. Number(e.actualQuantity)
  438. );
  439. amountSum = _.add(amountSum, Number(e.amount));
  440. purchaseAmountSum = _.add(
  441. purchaseAmountSum,
  442. Number(e.purchaseAmount)
  443. );
  444. });
  445. //数量总计
  446. if (item.property == "minOrder") {
  447. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  448. }
  449. //入库金额总计
  450. if (item.property == "predictOceanFreight") {
  451. sums[index] = micrometerFormat(instoreSum);
  452. }
  453. //金额总计
  454. if (item.property == "referenceOceanFreight") {
  455. sums[index] = micrometerFormat(totalSum);
  456. }
  457. //实际海运费
  458. if (item.property == "oceanFreight") {
  459. sums[index] = micrometerFormat(oceanFreightSum);
  460. }
  461. if (item.property == "orderQuantity") {
  462. sums[index] = orderQuantitySum
  463. ? orderQuantitySum.toFixed(2)
  464. : "0.00";
  465. }
  466. if (item.property == "actualQuantity") {
  467. sums[index] = actualQuantitySum
  468. ? actualQuantitySum.toFixed(2)
  469. : "0.00";
  470. }
  471. if (item.property == "amount") {
  472. sums[index] = micrometerFormat(amountSum);
  473. }
  474. if (item.property == "purchaseAmount") {
  475. sums[index] = micrometerFormat(purchaseAmountSum);
  476. }
  477. }
  478. });
  479. }
  480. return sums;
  481. },
  482. async saveColumn() {
  483. const inSave = await this.saveColumnData(
  484. this.getColumnName(4),
  485. this.option
  486. );
  487. if (inSave) {
  488. this.$nextTick(() => {
  489. this.$refs.crud.doLayout();
  490. });
  491. this.$message.success("保存成功");
  492. //关闭窗口
  493. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  494. }
  495. },
  496. async resetColumn() {
  497. this.option = option;
  498. const inSave = await this.delColumnData(this.getColumnName(4), option);
  499. if (inSave) {
  500. this.$nextTick(() => {
  501. this.$refs.crud.doLayout();
  502. });
  503. this.$message.success("重置成功");
  504. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  505. }
  506. }
  507. },
  508. watch: {
  509. option: function() {
  510. this.search.businesDate = defaultDate();
  511. }
  512. }
  513. };
  514. </script>
  515. <style scoped>
  516. ::v-deep .select-component {
  517. display: flex;
  518. }
  519. .page-crad ::v-deep .basic-container__card {
  520. height: 94.2vh;
  521. }
  522. .itemTable ::v-deep .el-table {
  523. width: 738px;
  524. }
  525. </style>