index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. :cell-style="cellStyle"
  19. :summary-method="summaryMethod"
  20. @selection-change="selectionChange"
  21. >
  22. <template slot-scope="{ row }" slot="createUser">
  23. <span>{{ row.createUserName }}</span>
  24. </template>
  25. <template slot="portOfLoadSearch">
  26. <port-info v-model="search.portOfLoad" />
  27. </template>
  28. <template slot="portOfDestinationSearch">
  29. <port-info v-model="search.portOfDestination" />
  30. </template>
  31. <template slot="businesDateSearch">
  32. <el-date-picker
  33. v-model="search.businesDate"
  34. type="daterange"
  35. start-placeholder="开始日期"
  36. end-placeholder="结束日期"
  37. format="yyyy-MM-dd"
  38. value-format="yyyy-MM-dd HH:mm:ss"
  39. :default-time="['00:00:00', '23:59:59']"
  40. >
  41. </el-date-picker>
  42. </template>
  43. <template slot="dateValiditySearch">
  44. <el-date-picker
  45. v-model="search.dateValidity"
  46. type="daterange"
  47. start-placeholder="开始日期"
  48. end-placeholder="结束日期"
  49. format="yyyy-MM-dd"
  50. value-format="yyyy-MM-dd HH:mm:ss"
  51. :default-time="['00:00:00', '23:59:59']"
  52. >
  53. </el-date-picker>
  54. </template>
  55. <template slot="createTimeSearch">
  56. <el-date-picker
  57. v-model="search.createTime"
  58. type="daterange"
  59. start-placeholder="开始日期"
  60. end-placeholder="结束日期"
  61. format="yyyy-MM-dd"
  62. value-format="yyyy-MM-dd HH:mm:ss"
  63. :default-time="['00:00:00', '23:59:59']"
  64. >
  65. </el-date-picker>
  66. </template>
  67. <template slot="menuLeft">
  68. <el-button
  69. type="primary"
  70. icon="el-icon-plus"
  71. size="small"
  72. @click.stop="newAdd()"
  73. >创建单据 </el-button
  74. >
  75. <el-button type="success" size="small" disabled>复制单据</el-button>
  76. <el-button type="info" size="small">报表</el-button>
  77. </template>
  78. <template slot="corpIdSearch">
  79. <crop-select
  80. v-model="search.corpId"
  81. corpType="KH"
  82. ></crop-select>
  83. </template>
  84. <template slot-scope="scope" slot="corpId">
  85. {{ scope.row.corpsName }}
  86. </template>
  87. <template slot-scope="scope" slot="grossProfitRate">
  88. {{ scope.row.grossProfitRate ? scope.row.grossProfitRate : 0 }}%
  89. </template>
  90. <template slot-scope="scope" slot="menu">
  91. <el-button
  92. type="text"
  93. icon="el-icon-edit"
  94. size="small"
  95. @click.stop="editOpen(scope.row, 2)"
  96. >编辑
  97. </el-button>
  98. <el-button
  99. type="text"
  100. icon="el-icon-delete"
  101. size="small"
  102. @click.stop="rowDel(scope.row, scope.index)"
  103. >删除
  104. </el-button>
  105. </template>
  106. </avue-crud>
  107. </basic-container>
  108. <detail-page
  109. @goBack="goBack"
  110. :detailData="detailData"
  111. v-if="!show"
  112. ></detail-page>
  113. </div>
  114. </template>
  115. <script>
  116. import option from "./config/mainList.json";
  117. import { getList, remove, gainUser } from "@/api/basicData/customerInquiry";
  118. import detailPage from "./detailsPage.vue";
  119. import { defaultDate } from "@/util/date";
  120. import { micrometerFormat } from "@/util/validate";
  121. import _ from "lodash";
  122. export default {
  123. name: "customerInformation",
  124. data() {
  125. return {
  126. search: {
  127. businesDate: defaultDate()
  128. },
  129. form: {},
  130. option: {},
  131. parentId: 0,
  132. dataList: [],
  133. page: {
  134. pageSize: 10,
  135. currentPage: 1,
  136. total: 0,
  137. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  138. },
  139. show: true,
  140. detailData: {},
  141. loading: false,
  142. searchShow: true,
  143. selectionList: []
  144. };
  145. },
  146. components: { detailPage },
  147. async created() {
  148. /**
  149. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  150. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  151. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  152. */
  153. this.option = await this.getColumnData(this.getColumnName(0), option);
  154. this.getWorkDicts("order_status").then(res => {
  155. this.findObject(this.option.column, "orderStatus").dicData =
  156. res.data.data;
  157. });
  158. gainUser().then(res => {
  159. this.findObject(this.option.column, "createUser").dicData = res.data.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).then(res => {
  174. if (res.data.code == 200) {
  175. this.$message({
  176. type: "success",
  177. message: "删除成功!"
  178. });
  179. this.onLoad(this.page, this.search);
  180. }
  181. });
  182. });
  183. },
  184. selectionChange(list) {
  185. this.selectionList = list;
  186. },
  187. //查看跳转页面
  188. beforeOpenPage(row, status) {
  189. this.detailData = {
  190. id: row.id,
  191. status: status
  192. };
  193. this.show = false;
  194. },
  195. editOpen(row, status) {
  196. this.detailData = {
  197. id: row.id,
  198. status: status
  199. };
  200. this.show = false;
  201. },
  202. //点击搜索按钮触发
  203. searchChange(params, done) {
  204. if (params.businesDate) {
  205. params.orderStartDate = params.businesDate[0];
  206. params.orderEndDate = params.businesDate[1];
  207. }
  208. if (params.dateValidity) {
  209. params.dateValidityStart = params.dateValidity[0];
  210. params.dateValidityEnd = params.dateValidity[1];
  211. }
  212. if (params.createTime) {
  213. params.createTimeStart = params.createTime[0];
  214. params.createTimeEnd = params.createTime[1];
  215. }
  216. delete params.businesDate;
  217. delete params.dateValidity;
  218. delete params.createTime;
  219. this.page.currentPage = 1;
  220. this.onLoad(this.page, params);
  221. done();
  222. },
  223. currentChange(val) {
  224. this.page.currentPage = val;
  225. },
  226. sizeChange(val) {
  227. this.page.currentPage = 1;
  228. this.page.pageSize = val;
  229. },
  230. onLoad(page, params) {
  231. if (this.search.businesDate && this.search.businesDate.length > 0) {
  232. params = {
  233. ...params,
  234. orderStartDate: this.search.businesDate[0],
  235. orderEndDate: this.search.businesDate[1]
  236. };
  237. delete params.businesDate;
  238. }
  239. this.loading = true;
  240. getList(page.currentPage, page.pageSize, params)
  241. .then(res => {
  242. this.dataList = res.data.data.records ? res.data.data.records : [];
  243. this.page.total = res.data.data.total;
  244. if (this.page.total) {
  245. this.option.height = window.innerHeight - 350;
  246. }
  247. })
  248. .finally(() => {
  249. this.loading = false;
  250. });
  251. },
  252. summaryMethod({ columns, data }) {
  253. const sums = [];
  254. if (columns.length > 0) {
  255. columns.forEach((item, index) => {
  256. sums[0] = "合计";
  257. if (
  258. item.property == "orderQuantity" ||
  259. item.property == "amount" ||
  260. item.property == "purchaseAmount"
  261. ) {
  262. let qtySum = 0;
  263. let instoreSum = 0;
  264. let totalSum = 0;
  265. data.forEach(e => {
  266. qtySum = _.add(qtySum, Number(e.orderQuantity));
  267. instoreSum = _.add(instoreSum, Number(e.amount));
  268. totalSum = _.add(totalSum, Number(e.purchaseAmount));
  269. });
  270. //数量总计
  271. if (item.property == "orderQuantity") {
  272. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  273. }
  274. //入库金额总计
  275. if (item.property == "amount") {
  276. sums[index] = micrometerFormat(instoreSum);
  277. }
  278. //金额总计
  279. if (item.property == "purchaseAmount") {
  280. sums[index] = micrometerFormat(totalSum);
  281. }
  282. }
  283. });
  284. }
  285. return sums;
  286. },
  287. refreshChange() {
  288. this.onLoad(this.page, this.search);
  289. },
  290. newAdd() {
  291. this.show = false;
  292. },
  293. goBack() {
  294. this.detailData = this.$options.data().detailData;
  295. this.show = true;
  296. this.onLoad(this.page, this.search);
  297. },
  298. async saveColumn() {
  299. /**
  300. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  301. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  302. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  303. */
  304. const inSave = await this.saveColumnData(
  305. this.getColumnName(0),
  306. this.option
  307. );
  308. if (inSave) {
  309. this.$message.success("保存成功");
  310. //关闭窗口
  311. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  312. }
  313. }
  314. },
  315. watch: {
  316. option: function() {
  317. this.search.businesDate = defaultDate();
  318. }
  319. }
  320. };
  321. </script>
  322. <style scoped>
  323. ::v-deep .select-component {
  324. display: flex;
  325. }
  326. .page-crad ::v-deep .basic-container__card {
  327. height: 94.2vh;
  328. }
  329. </style>