index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 { getList, remove, getPorts } from "@/api/basicData/purchaseInquiry";
  103. import detailPage from "./detailsPage.vue";
  104. import { defaultDate } from "@/util/date";
  105. import { micrometerFormat } from "@/util/validate";
  106. import _ from "lodash";
  107. export default {
  108. name: "customerInformation",
  109. data() {
  110. return {
  111. configuration: {
  112. multipleChoices: false,
  113. multiple: false,
  114. collapseTags: false,
  115. placeholder: "请点击右边按钮选择",
  116. dicData: []
  117. },
  118. search: {
  119. businesDate: defaultDate()
  120. },
  121. option: {},
  122. parentId: 0,
  123. dataList: [],
  124. page: {
  125. pageSize: 10,
  126. currentPage: 1,
  127. total: 0
  128. },
  129. show: true,
  130. detailData: {},
  131. loading: false
  132. };
  133. },
  134. components: { detailPage },
  135. async created() {
  136. this.option = await this.getColumnData(this.getColumnName(10), option);
  137. let _this = this;
  138. this.option.column.forEach(e => {
  139. if (e.prop == "exchangeRate") {
  140. e.formatter = function(row) {
  141. return _this.textFormat(
  142. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  143. "0.00%"
  144. );
  145. };
  146. }
  147. if (e.prop == "creditAmount") {
  148. e.formatter = function(row) {
  149. return _this.textFormat(
  150. Number(row.creditAmount ? row.creditAmount : 0),
  151. "#,##0.00"
  152. );
  153. };
  154. }
  155. });
  156. getPorts().then(res => {
  157. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  158. this.findObject(this.option.column, "portOfDestination").dicData =
  159. res.data;
  160. });
  161. },
  162. methods: {
  163. cellStyle() {
  164. return "padding:0;height:40px;";
  165. },
  166. //删除列表后面的删除按钮触发触发(row, index, done)
  167. rowDel(row, index, done) {
  168. this.$confirm("确定将选择数据删除?", {
  169. confirmButtonText: "确定",
  170. cancelButtonText: "取消",
  171. type: "warning"
  172. }).then(() => {
  173. remove(row.id);
  174. this.$message({
  175. type: "success",
  176. message: "操作成功!"
  177. });
  178. this.page.currentPage = 1;
  179. this.onLoad(this.page);
  180. });
  181. },
  182. //查看跳转页面
  183. beforeOpenPage(row, status) {
  184. this.detailData = {
  185. id: row.id,
  186. status: status
  187. };
  188. this.show = false;
  189. },
  190. editOpen(row, status) {
  191. this.detailData = {
  192. id: row.id,
  193. status: status
  194. };
  195. this.show = false;
  196. },
  197. //点击搜索按钮触发
  198. searchChange(params, done) {
  199. if (params.businesDate) {
  200. params.orderStartDate = params.businesDate[0];
  201. params.orderEndDate = params.businesDate[1];
  202. }
  203. if (params.dateValidity) {
  204. params.plannedDeliveryStart = params.dateValidity[0];
  205. params.plannedDeliveryEnd = params.dateValidity[1];
  206. }
  207. if (params.createTime) {
  208. params.createTimeStart = params.createTime[0];
  209. params.createTimeEnd = params.createTime[1];
  210. }
  211. delete params.businesDate;
  212. delete params.dateValidity;
  213. delete params.createTime;
  214. this.page.currentPage = 1;
  215. this.onLoad(this.page, params);
  216. done();
  217. },
  218. currentChange(val) {
  219. this.page.currentPage = val;
  220. },
  221. sizeChange(val) {
  222. this.page.currentPage = 1;
  223. this.page.pageSize = val;
  224. },
  225. onLoad(page, params) {
  226. if (this.search.businesDate && this.search.businesDate.length > 0) {
  227. params = {
  228. ...params,
  229. orderStartDate: this.search.businesDate[0],
  230. orderEndDate: this.search.businesDate[1]
  231. };
  232. delete params.businesDate;
  233. }
  234. this.loading = true;
  235. getList(page.currentPage, page.pageSize, params)
  236. .then(res => {
  237. this.dataList = res.data.data.records ? res.data.data.records : [];
  238. this.page.total = res.data.data.total;
  239. if (this.page.total) {
  240. this.option.height = window.innerHeight - 450;
  241. }
  242. })
  243. .finally(() => {
  244. this.loading = false;
  245. });
  246. },
  247. refreshChange() {
  248. this.onLoad(this.page, this.search);
  249. },
  250. newAdd() {
  251. this.show = false;
  252. },
  253. goBack() {
  254. this.detailData = this.$options.data().detailData;
  255. this.show = true;
  256. },
  257. summaryMethod({ columns, data }) {
  258. const sums = [];
  259. if (columns.length > 0) {
  260. columns.forEach((item, index) => {
  261. sums[0] = "合计";
  262. if (item.property == "orderQuantity") {
  263. let qtySum = 0;
  264. data.forEach(e => {
  265. qtySum = _.add(qtySum, Number(e.orderQuantity));
  266. });
  267. //数量总计
  268. if (item.property == "orderQuantity") {
  269. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  270. }
  271. }
  272. });
  273. }
  274. return sums;
  275. },
  276. async saveColumn() {
  277. const inSave = await this.saveColumnData(
  278. this.getColumnName(10),
  279. this.option
  280. );
  281. if (inSave) {
  282. this.$message.success("保存成功");
  283. //关闭窗口
  284. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  285. }
  286. }
  287. },
  288. watch: {
  289. option: function() {
  290. this.search.businesDate = defaultDate();
  291. }
  292. }
  293. };
  294. </script>
  295. <style scoped>
  296. ::v-deep .select-component {
  297. display: flex;
  298. }
  299. .page-crad ::v-deep .basic-container__card {
  300. height: 86.5vh;
  301. }
  302. </style>