index.vue 8.7 KB

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