index.vue 6.4 KB

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