index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div>
  3. <basic-container v-if="show">
  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. >
  17. <template slot="menuLeft">
  18. <el-button
  19. type="primary"
  20. icon="el-icon-plus"
  21. size="small"
  22. @click.stop="newAdd('new')"
  23. >新单</el-button
  24. >
  25. <el-button type="success" size="small" disabled>复制新单</el-button>
  26. <el-button type="info" size="small">报表</el-button>
  27. </template>
  28. <template slot="corpIdSearch">
  29. <select-component
  30. v-model="search.corpId"
  31. :configuration="configuration"
  32. ></select-component>
  33. </template>
  34. <template slot="portOfLoadSearch">
  35. <port-info v-model="search.portOfLoad" />
  36. </template>
  37. <template slot="portOfDestinationSearch">
  38. <port-info v-model="search.portOfDestination" />
  39. </template>
  40. <template slot="businesDateSearch">
  41. <el-date-picker
  42. v-model="search.businesDate"
  43. type="daterange"
  44. start-placeholder="开始日期"
  45. end-placeholder="结束日期"
  46. format="yyyy-MM-dd"
  47. value-format="yyyy-MM-dd HH:mm:ss"
  48. :default-time="['00:00:00', '23:59:59']"
  49. >
  50. </el-date-picker>
  51. </template>
  52. <template slot-scope="scope" slot="corpId">
  53. {{ scope.row.corpsName }}
  54. </template>
  55. <template slot-scope="scope" slot="menu">
  56. <el-button
  57. type="text"
  58. icon="el-icon-view"
  59. size="small"
  60. @click.stop="beforeOpenPage(scope.row, 1)"
  61. >查看
  62. </el-button>
  63. <el-button
  64. type="text"
  65. icon="el-icon-edit"
  66. size="small"
  67. @click.stop="editOpen(scope.row, 2)"
  68. >编辑
  69. </el-button>
  70. <el-button
  71. type="text"
  72. icon="el-icon-delete"
  73. size="small"
  74. @click.stop="rowDel(scope.row, scope.index)"
  75. >删除
  76. </el-button>
  77. </template>
  78. </avue-crud>
  79. </basic-container>
  80. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  81. </div>
  82. </template>
  83. <script>
  84. import option from "./config/mainList.json";
  85. import { getList, remove, getPorts } from "@/api/basicData/salesContract";
  86. import detailPage from "./detailsPage.vue";
  87. export default {
  88. name: "customerInformation",
  89. data() {
  90. return {
  91. configuration: {
  92. multipleChoices: false,
  93. multiple: false,
  94. collapseTags: false,
  95. placeholder: "请点击右边按钮选择",
  96. dicData: []
  97. },
  98. search: {},
  99. form: {},
  100. option: option,
  101. parentId: 0,
  102. dataList: [],
  103. page: {
  104. pageSize: 10,
  105. currentPage: 1,
  106. total: 0
  107. },
  108. show: true,
  109. detailData: {},
  110. loading: false
  111. };
  112. },
  113. components: { detailPage },
  114. created() {
  115. let _this = this;
  116. this.option.column.forEach(e => {
  117. if (e.prop == "exchangeRate") {
  118. e.formatter = function(row) {
  119. return _this.textFormat(
  120. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  121. "0.00%"
  122. );
  123. };
  124. }
  125. if (e.prop == "creditAmount") {
  126. e.formatter = function(row) {
  127. return _this.textFormat(
  128. Number(row.creditAmount ? row.creditAmount : 0),
  129. "#,##0.00"
  130. );
  131. };
  132. }
  133. });
  134. getPorts().then(res => {
  135. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  136. this.findObject(this.option.column, "portOfDestination").dicData =
  137. res.data;
  138. });
  139. },
  140. methods: {
  141. //删除列表后面的删除按钮触发触发(row, index, done)
  142. rowDel(row, index, done) {
  143. this.$confirm("确定删除数据?", {
  144. confirmButtonText: "确定",
  145. cancelButtonText: "取消",
  146. type: "warning"
  147. }).then(() => {
  148. remove(row.id);
  149. this.$message({
  150. type: "success",
  151. message: "删除成功!"
  152. });
  153. this.page.currentPage = 1;
  154. this.onLoad(this.page);
  155. });
  156. },
  157. //查看跳转页面
  158. beforeOpenPage(row, status) {
  159. this.detailData = {
  160. id: row.id,
  161. status: status
  162. };
  163. this.show = false;
  164. },
  165. editOpen(row, status) {
  166. this.detailData = {
  167. id: row.id,
  168. status: status
  169. };
  170. this.show = false;
  171. },
  172. //点击搜索按钮触发
  173. searchChange(params, done) {
  174. if (params.businesDate) {
  175. params.orderStartDate = params.businesDate[0];
  176. params.orderEndDate = params.businesDate[1];
  177. }
  178. delete params.businesDate;
  179. this.page.currentPage = 1;
  180. this.onLoad(this.page, params);
  181. done();
  182. },
  183. currentChange(val) {
  184. this.page.currentPage = val;
  185. },
  186. sizeChange(val) {
  187. this.page.currentPage = 1;
  188. this.page.pageSize = val;
  189. },
  190. onLoad(page, params) {
  191. getList(page.currentPage, page.pageSize, params).then(res => {
  192. this.dataList = res.data.data.records ? res.data.data.records : [];
  193. this.page.total = res.data.data.total;
  194. if (this.page.total) {
  195. this.option.height = window.innerHeight - 380;
  196. } else {
  197. this.option.height = window.innerHeight - 305;
  198. }
  199. });
  200. },
  201. refreshChange() {
  202. this.onLoad(this.page, this.search);
  203. },
  204. newAdd(type) {
  205. this.detailData = {
  206. pageType: type
  207. };
  208. this.show = false;
  209. },
  210. goBack() {
  211. this.detailData = this.$options.data().detailData;
  212. this.show = true;
  213. }
  214. }
  215. };
  216. </script>
  217. <style scoped>
  218. ::v-deep .select-component {
  219. display: flex;
  220. }
  221. </style>