index.vue 8.0 KB

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