index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. :summary-method="summaryMethod"
  19. :cell-style="cellStyle"
  20. >
  21. <template slot="menuLeft">
  22. <el-button
  23. type="primary"
  24. icon="el-icon-plus"
  25. size="small"
  26. @click.stop="newAdd()"
  27. >新单</el-button
  28. >
  29. <el-button type="info" size="small">报表</el-button>
  30. </template>
  31. <template slot="corpIdSearch">
  32. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  33. </template>
  34. <template slot="businesDateSearch">
  35. <el-date-picker
  36. v-model="search.businesDate"
  37. type="daterange"
  38. start-placeholder="开始日期"
  39. end-placeholder="结束日期"
  40. format="yyyy-MM-dd"
  41. value-format="yyyy-MM-dd HH:mm:ss"
  42. :default-time="['00:00:00', '23:59:59']"
  43. >
  44. </el-date-picker>
  45. </template>
  46. <template slot="dateValiditySearch">
  47. <el-date-picker
  48. v-model="search.dateValidity"
  49. type="daterange"
  50. start-placeholder="开始日期"
  51. end-placeholder="结束日期"
  52. format="yyyy-MM-dd"
  53. value-format="yyyy-MM-dd HH:mm:ss"
  54. :default-time="['00:00:00', '23:59:59']"
  55. >
  56. </el-date-picker>
  57. </template>
  58. <template slot="createTimeSearch">
  59. <el-date-picker
  60. v-model="search.createTime"
  61. type="daterange"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. format="yyyy-MM-dd"
  65. value-format="yyyy-MM-dd HH:mm:ss"
  66. :default-time="['00:00:00', '23:59:59']"
  67. >
  68. </el-date-picker>
  69. </template>
  70. <template slot-scope="{ row }" slot="createUser">
  71. <span>{{ row.createUserName }}</span>
  72. </template>
  73. <template slot-scope="scope" slot="corpId">
  74. {{ scope.row.corpName }}
  75. </template>
  76. <template slot-scope="scope" slot="menu">
  77. <el-button
  78. type="text"
  79. icon="el-icon-edit"
  80. size="small"
  81. @click.stop="editOpen(scope.row, 2)"
  82. >编辑
  83. </el-button>
  84. <el-button
  85. type="text"
  86. icon="el-icon-delete"
  87. size="small"
  88. @click.stop="rowDel(scope.row, scope.index)"
  89. >删除
  90. </el-button>
  91. </template>
  92. </avue-crud>
  93. </basic-container>
  94. <detail-page @goBack="goBack" :detailData="detailData" v-if="!show"></detail-page>
  95. </div>
  96. </template>
  97. <script>
  98. import option from "./config/mainList.json";
  99. import {
  100. getList,
  101. remove,
  102. getPorts,
  103. gainUser
  104. } from "@/api/basicData/purchaseInquiry";
  105. import detailPage from "./detailsPage.vue";
  106. import { defaultDate } from "@/util/date";
  107. import { micrometerFormat } from "@/util/validate";
  108. import _ from "lodash";
  109. export default {
  110. name: "customerInformation",
  111. data() {
  112. return {
  113. search: {
  114. businesDate: defaultDate()
  115. },
  116. option: {},
  117. parentId: 0,
  118. dataList: [],
  119. page: {
  120. pageSize: 10,
  121. currentPage: 1,
  122. total: 0,
  123. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  124. },
  125. show: true,
  126. detailData: {},
  127. loading: false
  128. };
  129. },
  130. components: { detailPage },
  131. async created() {
  132. this.option = await this.getColumnData(this.getColumnName(10), option);
  133. getPorts().then(res => {
  134. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  135. this.findObject(this.option.column, "portOfDestination").dicData =
  136. res.data;
  137. });
  138. gainUser().then(res => {
  139. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  140. });
  141. },
  142. methods: {
  143. cellStyle() {
  144. return "padding:0;height:40px;";
  145. },
  146. //删除列表后面的删除按钮触发触发(row, index, done)
  147. rowDel(row, index, done) {
  148. this.$confirm("确定删除数据?", {
  149. confirmButtonText: "确定",
  150. cancelButtonText: "取消",
  151. type: "warning"
  152. }).then(() => {
  153. remove(row.id).then(res => {
  154. if (res.data.code == 200) {
  155. this.$message({
  156. type: "success",
  157. message: "删除成功!"
  158. });
  159. this.onLoad(this.page, this.search);
  160. }
  161. });
  162. });
  163. },
  164. //查看跳转页面
  165. beforeOpenPage(row, status) {
  166. this.detailData = {
  167. id: row.id,
  168. status: status
  169. };
  170. this.show = false;
  171. },
  172. editOpen(row, status) {
  173. this.detailData = {
  174. id: row.id,
  175. status: status
  176. };
  177. this.show = false;
  178. },
  179. //点击搜索按钮触发
  180. searchChange(params, done) {
  181. if (params.businesDate) {
  182. params.orderStartDate = params.businesDate[0];
  183. params.orderEndDate = params.businesDate[1];
  184. }
  185. if (params.dateValidity) {
  186. params.plannedDeliveryStart = params.dateValidity[0];
  187. params.plannedDeliveryEnd = params.dateValidity[1];
  188. }
  189. if (params.createTime) {
  190. params.createTimeStart = params.createTime[0];
  191. params.createTimeEnd = params.createTime[1];
  192. }
  193. delete params.businesDate;
  194. delete params.dateValidity;
  195. delete params.createTime;
  196. this.page.currentPage = 1;
  197. this.onLoad(this.page, params);
  198. done();
  199. },
  200. currentChange(val) {
  201. this.page.currentPage = val;
  202. },
  203. sizeChange(val) {
  204. this.page.currentPage = 1;
  205. this.page.pageSize = val;
  206. },
  207. onLoad(page, params) {
  208. if (this.search.businesDate && this.search.businesDate.length > 0) {
  209. params = {
  210. ...params,
  211. orderStartDate: this.search.businesDate[0],
  212. orderEndDate: this.search.businesDate[1]
  213. };
  214. delete params.businesDate;
  215. }
  216. this.loading = true;
  217. getList(page.currentPage, page.pageSize, params)
  218. .then(res => {
  219. this.dataList = res.data.data.records ? res.data.data.records : [];
  220. this.page.total = res.data.data.total;
  221. if (this.page.total) {
  222. this.option.height = window.innerHeight - 350;
  223. }
  224. })
  225. .finally(() => {
  226. this.loading = false;
  227. });
  228. },
  229. refreshChange() {
  230. this.onLoad(this.page, this.search);
  231. },
  232. newAdd() {
  233. this.show = false;
  234. },
  235. goBack() {
  236. this.detailData = this.$options.data().detailData;
  237. this.show = true;
  238. this.onLoad(this.page, this.search);
  239. },
  240. summaryMethod({ columns, data }) {
  241. const sums = [];
  242. if (columns.length > 0) {
  243. columns.forEach((item, index) => {
  244. sums[0] = "合计";
  245. if (item.property == "orderQuantity") {
  246. let qtySum = 0;
  247. data.forEach(e => {
  248. qtySum = _.add(qtySum, Number(e.orderQuantity));
  249. });
  250. //数量总计
  251. if (item.property == "orderQuantity") {
  252. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  253. }
  254. }
  255. });
  256. }
  257. return sums;
  258. },
  259. async saveColumn() {
  260. const inSave = await this.saveColumnData(
  261. this.getColumnName(10),
  262. this.option
  263. );
  264. if (inSave) {
  265. this.$message.success("保存成功");
  266. //关闭窗口
  267. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  268. }
  269. }
  270. },
  271. watch: {
  272. option: function() {
  273. this.search.businesDate = defaultDate();
  274. }
  275. }
  276. };
  277. </script>
  278. <style scoped>
  279. ::v-deep .select-component {
  280. display: flex;
  281. }
  282. .page-crad ::v-deep .basic-container__card {
  283. height: 94.2vh;
  284. }
  285. </style>