index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
  5. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  7. @resetColumn="resetColumn" :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
  8. <template slot="menuLeft">
  9. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="newAdd()">新增
  10. </el-button>
  11. </template>
  12. <template slot="outHarborNameSearch">
  13. <port-info v-model="search.outHarborName" />
  14. </template>
  15. <template slot-scope="{ row, index }" slot="menu">
  16. <el-button type="text" size="small" @click.stop="editOpen(row,2)">
  17. 查看
  18. </el-button>
  19. <el-button type="text" size="small" @click.stop="rowDel(row, index)">
  20. 删除
  21. </el-button>
  22. </template>
  23. </avue-crud>
  24. </basic-container>
  25. <details-page v-if="!show" @goBack="backToList" :detailData="detailData" />
  26. </div>
  27. </template>
  28. <script>
  29. import detailsPage from "./detailsPage";
  30. import { option } from "./js/optionList";
  31. import { getList, remove } from "@/api/maintenance/landFreight";
  32. import { areaTypeTree } from "@/api/basicData/customerInformation";
  33. export default {
  34. name: "index",
  35. data() {
  36. return {
  37. show: true,
  38. loading: false,
  39. form: {},
  40. search: {},
  41. detailData: {},
  42. dataList: [],
  43. selectionList: [],
  44. page: {
  45. pageSize: 10,
  46. currentPage: 1,
  47. total: 0,
  48. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  49. },
  50. option: {},
  51. };
  52. },
  53. components: {
  54. detailsPage
  55. },
  56. async created() {
  57. this.option = await this.getColumnData(this.getColumnName(205), option);
  58. this.getAllWorkDicts()
  59. this.option.height = window.innerHeight - 210;
  60. },
  61. methods: {
  62. getAllWorkDicts() {
  63. this.getWorkDicts("cargo_type").then(res => {
  64. this.findObject(this.option.column, "goodsAttribute").dicData =
  65. res.data.data;
  66. });
  67. },
  68. searchCriteriaSwitch(type) {
  69. if (type) {
  70. this.option.height = this.option.height - 46;
  71. } else {
  72. this.option.height = this.option.height + 46;
  73. }
  74. this.$refs.crud.getTableHeight();
  75. },
  76. cellStyle() {
  77. return "padding:0;height:40px;";
  78. },
  79. //点击搜索按钮触发
  80. searchChange(params, done) {
  81. this.page.currentPage = 1;
  82. this.onLoad(this.page, params);
  83. done();
  84. },
  85. refreshChange() {
  86. this.onLoad(this.page, this.search);
  87. },
  88. newAdd() {
  89. this.show = false;
  90. },
  91. onLoad(page, params = {}) {
  92. this.loading = true;
  93. this.dataList.forEach(item => {
  94. this.$refs.crud.toggleRowExpansion(item, false);
  95. });
  96. let data = this.deepClone(Object.assign(params, this.search));
  97. data.feesType = 2
  98. getList(
  99. page.currentPage,
  100. page.pageSize,
  101. data
  102. )
  103. .then(res => {
  104. if (res.data.data.records) {
  105. res.data.data.records.forEach(e => {
  106. e.itemLoading = true;
  107. });
  108. }
  109. this.dataList = res.data.data.records ? res.data.data.records : [];
  110. this.page.total = res.data.data.total;
  111. })
  112. .finally(() => {
  113. this.loading = false;
  114. });
  115. },
  116. editOpen(row, status) {
  117. this.detailData = {
  118. id: row.id,
  119. status: status
  120. };
  121. this.show = false;
  122. },
  123. currentChange(val) {
  124. this.page.currentPage = val;
  125. },
  126. sizeChange(val) {
  127. this.page.currentPage = 1;
  128. this.page.pageSize = val;
  129. },
  130. rowDel(row, index, done) {
  131. this.$confirm("确定删除数据?", {
  132. confirmButtonText: "确定",
  133. cancelButtonText: "取消",
  134. type: "warning"
  135. }).then(() => {
  136. remove(row.id).then(res => {
  137. if (res.data.code == 200) {
  138. this.$message({
  139. type: "success",
  140. message: "删除成功!"
  141. });
  142. this.onLoad(this.page, this.search);
  143. }
  144. });
  145. });
  146. },
  147. async saveColumn() {
  148. const inSave = await this.saveColumnData(
  149. this.getColumnName(205),
  150. this.option
  151. );
  152. if (inSave) {
  153. this.$nextTick(() => {
  154. this.$refs.crud.doLayout();
  155. });
  156. this.$message.success("保存成功");
  157. //关闭窗口
  158. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  159. }
  160. },
  161. async resetColumn() {
  162. this.option = option;
  163. const inSave = await this.delColumnData(this.getColumnName(205), option);
  164. if (inSave) {
  165. this.$nextTick(() => {
  166. this.$refs.crud.doLayout();
  167. });
  168. this.$message.success("重置成功");
  169. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  170. }
  171. },
  172. //返回列表
  173. backToList() {
  174. this.detailData = this.$options.data().detailData;
  175. this.show = true;
  176. this.onLoad(this.page, this.search);
  177. }
  178. }
  179. };
  180. </script>
  181. <style scoped>
  182. .page-crad ::v-deep .basic-container__card {
  183. height: 94.2vh;
  184. }
  185. </style>