index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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-scope="{ row,index}" slot="contractNo">
  13. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.contractNo }}</span>
  14. </template>
  15. <template slot-scope="{ row,index}" slot="corpId">
  16. <span>{{ row.corpName }}</span>
  17. </template>
  18. <template slot-scope="{ row,index}" slot="status">
  19. <el-switch v-model="row.status" active-value="0" inactive-value="1" @change="switchChange(row)">
  20. </el-switch>
  21. </template>
  22. <template slot="corpIdSearch">
  23. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  24. </template>
  25. <template slot-scope="{ row, index }" slot="menu">
  26. <el-button type="text" size="small" :disabled="row.status==0" @click.stop="rowDel(row, index)">
  27. 删除
  28. </el-button>
  29. </template>
  30. </avue-crud>
  31. </basic-container>
  32. <details-page v-if="!show" @goBack="backToList" :detailData="detailData" />
  33. </div>
  34. </template>
  35. <script>
  36. import detailsPage from "./detailsPage";
  37. import { option } from "./js/optionList";
  38. import { getList, remove, submit } from "@/api/basicData/agreement";
  39. import { areaTypeTree } from "@/api/basicData/customerInformation";
  40. export default {
  41. name: "index",
  42. data() {
  43. return {
  44. show: true,
  45. loading: false,
  46. form: {},
  47. search: {},
  48. detailData: {},
  49. dataList: [],
  50. selectionList: [],
  51. page: {
  52. pageSize: 10,
  53. currentPage: 1,
  54. total: 0,
  55. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  56. },
  57. option: {},
  58. };
  59. },
  60. components: {
  61. detailsPage
  62. },
  63. async created() {
  64. this.option = await this.getColumnData(this.getColumnName(203), option);
  65. this.option.height = window.innerHeight - 210;
  66. this.getAllWorkDicts()
  67. },
  68. methods: {
  69. getAllWorkDicts() {
  70. areaTypeTree().then(res => {
  71. this.findObject(this.option.column, "portOfDestination").dicData = res.data.data;
  72. this.$refs.crud.init();
  73. });
  74. this.getWorkDicts("cargo_type").then(res => {
  75. this.findObject(this.option.column, "goodsProps").dicData =
  76. res.data.data;
  77. });
  78. },
  79. searchCriteriaSwitch(type) {
  80. if (type) {
  81. this.option.height = this.option.height - 46;
  82. } else {
  83. this.option.height = this.option.height + 46;
  84. }
  85. this.$refs.crud.getTableHeight();
  86. },
  87. cellStyle() {
  88. return "padding:0;height:40px;";
  89. },
  90. //点击搜索按钮触发
  91. searchChange(params, done) {
  92. this.page.currentPage = 1;
  93. this.onLoad(this.page, params);
  94. done();
  95. },
  96. refreshChange() {
  97. this.onLoad(this.page, this.search);
  98. },
  99. newAdd() {
  100. this.show = false;
  101. },
  102. onLoad(page, params = {}) {
  103. this.loading = true;
  104. this.dataList.forEach(item => {
  105. this.$refs.crud.toggleRowExpansion(item, false);
  106. });
  107. getList(
  108. page.currentPage,
  109. page.pageSize,
  110. Object.assign(params, this.search)
  111. )
  112. .then(res => {
  113. if (res.data.data.records) {
  114. res.data.data.records.forEach(e => {
  115. e.itemLoading = true;
  116. });
  117. }
  118. this.dataList = res.data.data.records ? res.data.data.records : [];
  119. this.page.total = res.data.data.total;
  120. })
  121. .finally(() => {
  122. this.loading = false;
  123. });
  124. },
  125. editOpen(row, status) {
  126. this.detailData = {
  127. id: row.id,
  128. status: status
  129. };
  130. this.show = false;
  131. },
  132. currentChange(val) {
  133. this.page.currentPage = val;
  134. },
  135. sizeChange(val) {
  136. this.page.currentPage = 1;
  137. this.page.pageSize = val;
  138. },
  139. rowDel(row, index, done) {
  140. this.$confirm("确定删除数据?", {
  141. confirmButtonText: "确定",
  142. cancelButtonText: "取消",
  143. type: "warning"
  144. }).then(() => {
  145. remove(row.id).then(res => {
  146. if (res.data.code == 200) {
  147. this.$message({
  148. type: "success",
  149. message: "删除成功!"
  150. });
  151. this.onLoad(this.page, this.search);
  152. }
  153. });
  154. });
  155. },
  156. switchChange(row) {
  157. this.$confirm("确定要" + row.stauts == 0 ? "开启" : "停用" + row.corpName + "吗?", {
  158. confirmButtonText: "确定",
  159. cancelButtonText: "取消",
  160. type: "warning"
  161. }).then(() => {
  162. submit({ ...row })
  163. .then(res => {
  164. this.$message.success("修改成功");
  165. })
  166. .finally(() => {
  167. this.onLoad(this.page, this.search);
  168. });
  169. });
  170. },
  171. async saveColumn() {
  172. const inSave = await this.saveColumnData(
  173. this.getColumnName(203),
  174. this.option
  175. );
  176. if (inSave) {
  177. this.$nextTick(() => {
  178. this.$refs.crud.doLayout();
  179. });
  180. this.$message.success("保存成功");
  181. //关闭窗口
  182. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  183. }
  184. },
  185. async resetColumn() {
  186. this.option = option;
  187. const inSave = await this.delColumnData(this.getColumnName(203), option);
  188. if (inSave) {
  189. this.$nextTick(() => {
  190. this.$refs.crud.doLayout();
  191. });
  192. this.getAllWorkDicts()
  193. this.$message.success("重置成功");
  194. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  195. }
  196. },
  197. //返回列表
  198. backToList() {
  199. this.detailData = this.$options.data().detailData;
  200. this.show = true;
  201. this.onLoad(this.page, this.search);
  202. }
  203. }
  204. };
  205. </script>
  206. <style scoped>
  207. .page-crad ::v-deep .basic-container__card {
  208. height: 94.2vh;
  209. }
  210. </style>