index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="销售区域选择"
  5. width="1000px"
  6. :close-on-click-modal="false"
  7. :append-to-body="true"
  8. v-dialogDrag
  9. class="userDialog"
  10. :visible.sync="visible"
  11. >
  12. <el-container style="height: 500px">
  13. <el-container>
  14. <el-header style="text-align: left; font-size: 12px; height: 30px">
  15. <el-form
  16. size="small"
  17. :inline="true"
  18. ref="searchForm"
  19. :model="searchForm"
  20. @keyup.enter.native="getList()"
  21. @submit.native.prevent
  22. >
  23. <el-form-item prop="code">
  24. <el-input
  25. size="small"
  26. v-model="queryParams.code"
  27. placeholder="区域编码"
  28. clearable
  29. ></el-input>
  30. </el-form-item>
  31. <el-form-item prop="name">
  32. <el-input
  33. size="small"
  34. v-model="queryParams.name"
  35. placeholder="区域名称"
  36. clearable
  37. ></el-input>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button
  41. type="primary"
  42. @click="getList()"
  43. size="small"
  44. icon="el-icon-search"
  45. >查询</el-button
  46. >
  47. <el-button
  48. @click="resetSearch()"
  49. size="small"
  50. icon="el-icon-refresh-right"
  51. >重置</el-button>
  52. </el-form-item>
  53. </el-form>
  54. </el-header>
  55. <el-main>
  56. <el-table
  57. :data="dataList"
  58. v-loading="loading"
  59. size="small"
  60. border
  61. ref="contractTable"
  62. @select="handleSelectionChange"
  63. height="calc(100% - 40px)"
  64. style="width: 100%"
  65. >
  66. <el-table-column
  67. type="selection"
  68. header-align="center"
  69. align="center"
  70. width="50"
  71. >
  72. </el-table-column>
  73. <el-table-column
  74. prop="code"
  75. header-align="center"
  76. align="left"
  77. sortable="custom"
  78. min-width="90"
  79. label="区域编码"
  80. >
  81. </el-table-column>
  82. <el-table-column
  83. prop="name"
  84. header-align="center"
  85. align="left"
  86. sortable="custom"
  87. min-width="90"
  88. label="区域名称"
  89. >
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination
  93. @size-change="sizeChangeHandle"
  94. @current-change="currentChangeHandle"
  95. :current-page="queryParams.pageNum"
  96. :page-sizes="[5, 10, 15, 20]"
  97. :page-size="queryParams.pageSize"
  98. :total="total"
  99. layout="total, sizes, prev, pager, next, jumper"
  100. >
  101. </el-pagination>
  102. </el-main>
  103. </el-container>
  104. </el-container>
  105. <span slot="footer" class="dialog-footer">
  106. <el-button
  107. size="small"
  108. @click="visible = false"
  109. icon="el-icon-circle-close"
  110. >关闭</el-button
  111. >
  112. <el-button
  113. size="small"
  114. type="primary"
  115. icon="el-icon-circle-check"
  116. @click="doSubmit()"
  117. >确定</el-button
  118. >
  119. </span>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. import { listSaleArea } from "@/api/business/spd/bo/iuapquery/basic";
  125. export default {
  126. data() {
  127. return {
  128. // 查询参数
  129. queryParams: {
  130. pageNum: 1,
  131. pageSize: 10,
  132. code: undefined,
  133. name: undefined,
  134. },
  135. searchForm: {
  136. code: '',
  137. name: ''
  138. },
  139. dataListAllSelections: [], // 所有选中的数据包含跨页数据
  140. idKey: "id", // 标识列表数据中每一行的唯一键的名称(需要按自己的数据改一下)
  141. dataList: [],
  142. pageNo: 1,
  143. pageSize: 10,
  144. total: 0,
  145. orders: [],
  146. loading: false,
  147. visible: false,
  148. };
  149. },
  150. props: {
  151. selectData: {
  152. type: Array,
  153. default: () => {
  154. return [];
  155. },
  156. },
  157. // 是否启用单选
  158. single: {
  159. type: Boolean,
  160. default: false
  161. }
  162. },
  163. methods: {
  164. init() {
  165. this.visible = true;
  166. this.$nextTick(() => {
  167. this.dataListAllSelections = JSON.parse(JSON.stringify(this.selectData));
  168. this.resetSearch();
  169. });
  170. },
  171. // 获取数据列表
  172. getList() {
  173. this.loading = true;
  174. listSaleArea(this.addDateRange(this.queryParams)).then(response => {
  175. this.dataList = response.rows;
  176. this.total = response.total;
  177. this.loading = false;
  178. }
  179. );
  180. },
  181. // 每页数
  182. sizeChangeHandle(val) {
  183. this.queryParams.pageSize = val;
  184. this.queryParams.pageNum = 1;
  185. this.getList();
  186. },
  187. // 当前页
  188. currentChangeHandle(val) {
  189. this.queryParams.pageNum = val;
  190. this.getList();
  191. },
  192. // 排序
  193. resetSearch() {
  194. this.$refs.searchForm.resetFields();
  195. this.getList();
  196. },
  197. // 选中数据
  198. handleSelectionChange(selection, row) {
  199. if (this.single && selection.length > 1) {
  200. this.$refs.contractTable.clearSelection();
  201. this.$refs.contractTable.toggleRowSelection(row);
  202. }
  203. this.dataListAllSelections = this.single ? [row] : selection
  204. },
  205. // 设置选中的方法
  206. setSelectRow() {
  207. this.$refs.contractTable.clearSelection();
  208. if (!this.dataListAllSelections || this.dataListAllSelections.length <= 0) {
  209. return;
  210. }
  211. for (let i = 0; i < this.dataList.length; i++) {
  212. if (this.dataListAllSelections.some(item => item[this.idKey] == this.dataList[i][this.idKey])) {
  213. // 设置选中,记住table组件需要使用ref="table"
  214. this.$refs.contractTable.toggleRowSelection(this.dataList[i], true);
  215. }
  216. }
  217. },
  218. doSubmit() {
  219. this.visible = false;
  220. console.log('选择的数据?',this.dataListAllSelections)
  221. this.$emit("doSubmit", this.dataListAllSelections);
  222. },
  223. },
  224. };
  225. </script>
  226. <style lang="scss">
  227. .userDialog {
  228. .el-dialog__body {
  229. padding: 10px 0px 0px 10px;
  230. color: #606266;
  231. font-size: 14px;
  232. word-break: break-all;
  233. }
  234. .el-main {
  235. padding: 20px 20px 5px 20px;
  236. .el-pagination {
  237. margin-top: 5px;
  238. }
  239. }
  240. }
  241. </style>