index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. :summary-method="summaryMethod"
  19. :cell-style="cellStyle"
  20. >
  21. <template slot="menuLeft">
  22. <el-button type="info" size="small">报表</el-button>
  23. </template>
  24. <template slot="corpIdSearch">
  25. <select-component
  26. v-model="search.corpId"
  27. :configuration="configuration"
  28. ></select-component>
  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-scope="{ row }" slot="createUser">
  67. <span>{{ row.createUserName }}</span>
  68. </template>
  69. <template slot-scope="scope" slot="corpId">
  70. {{ scope.row.corpName }}
  71. </template>
  72. <template slot-scope="scope" slot="menu">
  73. <el-button
  74. type="text"
  75. icon="el-icon-view"
  76. size="small"
  77. @click.stop="beforeOpenPage(scope.row, 1)"
  78. >查看
  79. </el-button>
  80. <el-button
  81. type="text"
  82. icon="el-icon-edit"
  83. size="small"
  84. @click.stop="editOpen(scope.row, 2)"
  85. >编辑
  86. </el-button>
  87. <el-button
  88. type="text"
  89. icon="el-icon-delete"
  90. size="small"
  91. @click.stop="rowDel(scope.row, scope.index)"
  92. >删除
  93. </el-button>
  94. </template>
  95. </avue-crud>
  96. </basic-container>
  97. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  98. </div>
  99. </template>
  100. <script>
  101. import option from "./config/mainList.json";
  102. import {
  103. getList,
  104. remove,
  105. getPorts,
  106. gainUser
  107. } from "@/api/basicData/purchaseInquiry";
  108. import detailPage from "./detailsPage.vue";
  109. import { defaultDate } from "@/util/date";
  110. import { micrometerFormat } from "@/util/validate";
  111. import _ from "lodash";
  112. export default {
  113. name: "customerInformation",
  114. data() {
  115. return {
  116. configuration: {
  117. multipleChoices: false,
  118. multiple: false,
  119. collapseTags: false,
  120. placeholder: "请点击右边按钮选择",
  121. dicData: []
  122. },
  123. search: {
  124. businesDate: defaultDate()
  125. },
  126. option: {},
  127. parentId: 0,
  128. dataList: [],
  129. page: {
  130. pageSize: 10,
  131. currentPage: 1,
  132. total: 0
  133. },
  134. show: true,
  135. detailData: {},
  136. loading: false
  137. };
  138. },
  139. components: { detailPage },
  140. async created() {
  141. this.option = await this.getColumnData(this.getColumnName(10), option);
  142. let _this = this;
  143. this.option.column.forEach(e => {
  144. if (e.prop == "exchangeRate") {
  145. e.formatter = function(row) {
  146. return _this.textFormat(
  147. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  148. "0.00%"
  149. );
  150. };
  151. }
  152. if (e.prop == "creditAmount") {
  153. e.formatter = function(row) {
  154. return _this.textFormat(
  155. Number(row.creditAmount ? row.creditAmount : 0),
  156. "#,##0.00"
  157. );
  158. };
  159. }
  160. });
  161. getPorts().then(res => {
  162. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  163. this.findObject(this.option.column, "portOfDestination").dicData =
  164. res.data;
  165. });
  166. gainUser().then(res => {
  167. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  168. });
  169. },
  170. methods: {
  171. cellStyle() {
  172. return "padding:0;height:40px;";
  173. },
  174. //删除列表后面的删除按钮触发触发(row, index, done)
  175. rowDel(row, index, done) {
  176. this.$confirm("确定将选择数据删除?", {
  177. confirmButtonText: "确定",
  178. cancelButtonText: "取消",
  179. type: "warning"
  180. }).then(() => {
  181. remove(row.id);
  182. this.$message({
  183. type: "success",
  184. message: "操作成功!"
  185. });
  186. this.page.currentPage = 1;
  187. this.onLoad(this.page);
  188. });
  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.plannedDeliveryStart = params.dateValidity[0];
  213. params.plannedDeliveryEnd = 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 - 450;
  249. }
  250. })
  251. .finally(() => {
  252. this.loading = false;
  253. });
  254. },
  255. refreshChange() {
  256. this.onLoad(this.page, this.search);
  257. },
  258. newAdd() {
  259. this.show = false;
  260. },
  261. goBack() {
  262. this.detailData = this.$options.data().detailData;
  263. this.show = true;
  264. },
  265. summaryMethod({ columns, data }) {
  266. const sums = [];
  267. if (columns.length > 0) {
  268. columns.forEach((item, index) => {
  269. sums[0] = "合计";
  270. if (item.property == "orderQuantity") {
  271. let qtySum = 0;
  272. data.forEach(e => {
  273. qtySum = _.add(qtySum, Number(e.orderQuantity));
  274. });
  275. //数量总计
  276. if (item.property == "orderQuantity") {
  277. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  278. }
  279. }
  280. });
  281. }
  282. return sums;
  283. },
  284. async saveColumn() {
  285. const inSave = await this.saveColumnData(
  286. this.getColumnName(10),
  287. this.option
  288. );
  289. if (inSave) {
  290. this.$message.success("保存成功");
  291. //关闭窗口
  292. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  293. }
  294. }
  295. },
  296. watch: {
  297. option: function() {
  298. this.search.businesDate = defaultDate();
  299. }
  300. }
  301. };
  302. </script>
  303. <style scoped>
  304. ::v-deep .select-component {
  305. display: flex;
  306. }
  307. .page-crad ::v-deep .basic-container__card {
  308. height: 86.5vh;
  309. }
  310. </style>