index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. :cell-style="cellStyle"
  19. >
  20. <template slot="portOfLoadSearch">
  21. <port-info v-model="search.portOfLoad" />
  22. </template>
  23. <template slot="portOfDestinationSearch">
  24. <port-info v-model="search.portOfDestination" />
  25. </template>
  26. <template slot="businesDateSearch">
  27. <el-date-picker
  28. v-model="search.businesDate"
  29. type="daterange"
  30. start-placeholder="开始日期"
  31. end-placeholder="结束日期"
  32. format="yyyy-MM-dd"
  33. value-format="yyyy-MM-dd HH:mm:ss"
  34. :default-time="['00:00:00', '23:59:59']"
  35. >
  36. </el-date-picker>
  37. </template>
  38. <template slot="menuLeft">
  39. <el-button
  40. type="primary"
  41. icon="el-icon-plus"
  42. size="small"
  43. @click.stop="newAdd()"
  44. >新单</el-button
  45. >
  46. <el-button type="success" size="small" disabled>复制新单</el-button>
  47. <el-button type="info" size="small">报表</el-button>
  48. </template>
  49. <template slot="corpIdSearch">
  50. <select-component
  51. v-model="search.corpId"
  52. :configuration="configuration"
  53. ></select-component>
  54. </template>
  55. <template slot-scope="scope" slot="corpId">
  56. {{ scope.row.corpsName }}
  57. </template>
  58. <template slot-scope="scope" slot="menu">
  59. <el-button
  60. type="text"
  61. icon="el-icon-view"
  62. size="small"
  63. @click.stop="beforeOpenPage(scope.row, 1)"
  64. >查看
  65. </el-button>
  66. <el-button
  67. type="text"
  68. icon="el-icon-edit"
  69. size="small"
  70. @click.stop="editOpen(scope.row, 2)"
  71. >编辑
  72. </el-button>
  73. <el-button
  74. type="text"
  75. icon="el-icon-delete"
  76. size="small"
  77. @click.stop="rowDel(scope.row, scope.index)"
  78. >删除
  79. </el-button>
  80. </template>
  81. </avue-crud>
  82. </basic-container>
  83. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  84. </div>
  85. </template>
  86. <script>
  87. import option from "./config/mainList.json";
  88. import { getList, remove } from "@/api/basicData/customerInquiry";
  89. import detailPage from "./detailsPage.vue";
  90. import { defaultDate } from "@/util/date";
  91. export default {
  92. name: "customerInformation",
  93. data() {
  94. return {
  95. configuration: {
  96. multipleChoices: false,
  97. multiple: false,
  98. collapseTags: false,
  99. placeholder: "请点击右边按钮选择",
  100. dicData: []
  101. },
  102. search: {},
  103. form: {},
  104. option: {},
  105. parentId: 0,
  106. dataList: [],
  107. page: {
  108. pageSize: 10,
  109. currentPage: 1,
  110. total: 0
  111. },
  112. show: true,
  113. detailData: {},
  114. loading: false
  115. };
  116. },
  117. components: { detailPage },
  118. async created() {
  119. this.search.businesDate=defaultDate()
  120. /**
  121. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  122. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  123. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  124. */
  125. this.option = await this.getColumnData(this.getColumnName(0), option);
  126. let _this = this;
  127. this.option.column.forEach(e => {
  128. if (e.prop == "exchangeRate") {
  129. e.formatter = function(row) {
  130. return _this.textFormat(
  131. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  132. "0.00%"
  133. );
  134. };
  135. }
  136. if (e.prop == "creditAmount") {
  137. e.formatter = function(row) {
  138. return _this.textFormat(
  139. Number(row.creditAmount ? row.creditAmount : 0),
  140. "#,##0.00"
  141. );
  142. };
  143. }
  144. });
  145. },
  146. methods: {
  147. cellStyle() {
  148. return "padding:0;height:40px;";
  149. },
  150. //删除列表后面的删除按钮触发触发(row, index, done)
  151. rowDel(row, index, done) {
  152. this.$confirm("确定删除数据?", {
  153. confirmButtonText: "确定",
  154. cancelButtonText: "取消",
  155. type: "warning"
  156. }).then(() => {
  157. remove(row.id);
  158. this.$message({
  159. type: "success",
  160. message: "删除成功!"
  161. });
  162. this.page.currentPage = 1;
  163. this.onLoad(this.page);
  164. });
  165. },
  166. //查看跳转页面
  167. beforeOpenPage(row, status) {
  168. this.detailData = {
  169. id: row.id,
  170. status: status
  171. };
  172. this.show = false;
  173. },
  174. editOpen(row, status) {
  175. this.detailData = {
  176. id: row.id,
  177. status: status
  178. };
  179. this.show = false;
  180. },
  181. //点击搜索按钮触发
  182. searchChange(params, done) {
  183. if (params.businesDate) {
  184. params.orderStartDate = params.businesDate[0];
  185. params.orderEndDate = params.businesDate[1];
  186. }
  187. delete params.businesDate;
  188. this.page.currentPage = 1;
  189. this.onLoad(this.page, params);
  190. done();
  191. },
  192. currentChange(val) {
  193. this.page.currentPage = val;
  194. },
  195. sizeChange(val) {
  196. this.page.currentPage = 1;
  197. this.page.pageSize = val;
  198. },
  199. onLoad(page, params) {
  200. if (this.search.businesDate.length>0) {
  201. params={
  202. orderStartDate:this.search.businesDate[0],
  203. orderEndDate:this.search.businesDate[1],
  204. }
  205. }
  206. this.loading = true;
  207. getList(page.currentPage, page.pageSize, params)
  208. .then(res => {
  209. this.dataList = res.data.data.records ? res.data.data.records : [];
  210. this.page.total = res.data.data.total;
  211. if (this.page.total) {
  212. this.option.height = window.innerHeight - 420;
  213. }
  214. })
  215. .finally(() => {
  216. this.loading = false;
  217. });
  218. },
  219. refreshChange() {
  220. this.onLoad(this.page, this.search);
  221. },
  222. newAdd() {
  223. this.show = false;
  224. },
  225. goBack() {
  226. this.detailData = this.$options.data().detailData;
  227. this.show = true;
  228. },
  229. async saveColumn() {
  230. /**
  231. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  232. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  233. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  234. */
  235. const inSave = await this.saveColumnData(
  236. this.getColumnName(0),
  237. this.option
  238. );
  239. if (inSave) {
  240. this.$message.success("保存成功");
  241. //关闭窗口
  242. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  243. }
  244. }
  245. }
  246. };
  247. </script>
  248. <style scoped>
  249. ::v-deep .select-component {
  250. display: flex;
  251. }
  252. .page-crad ::v-deep .basic-container__card {
  253. height: 86.5vh;
  254. }
  255. </style>