customerSelect.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <span class="select-component" style="display:inline-flex;">
  3. <el-select
  4. v-model="value"
  5. size="small"
  6. :placeholder="configuration.placeholder"
  7. style="width: 90%;border-right: none;"
  8. :disabled="disabled?disabled:false"
  9. :multiple="configuration.multiple?configuration.multiple:false"
  10. :collapse-tags="configuration.collapseTags?configuration.collapseTags:false">
  11. <el-option
  12. v-for="item in configuration.dicData.length !== 0?dicData.length !== 0?dicData:configuration.dicData:dicData"
  13. :key="item.id"
  14. :label="item.cname"
  15. :value="item.id"
  16. />
  17. </el-select>
  18. <el-button slot="append" icon="el-icon-edit" size="mini" @click="dialogVisible = true"
  19. :disabled="disabled?disabled:false"></el-button>
  20. <el-dialog
  21. v-dialogdrag
  22. title="导入客户"
  23. :visible.sync="dialogVisible"
  24. class="el-dialogDeep"
  25. top="0vh"
  26. bottom="2vh"
  27. append-to-body
  28. width="80%">
  29. <el-row style="margin-top: -5px;height: 0">
  30. <el-col :span="5">
  31. <div class="box">
  32. <el-scrollbar>
  33. <basic-container>
  34. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  35. </basic-container>
  36. </el-scrollbar>
  37. </div>
  38. </el-col>
  39. <el-col :span="19">
  40. <basic-container>
  41. <avue-crud :option="option"
  42. :data="dataList"
  43. ref="crud"
  44. v-model="form"
  45. :page.sync="page"
  46. :before-open="beforeOpen"
  47. :before-close="beforeClose"
  48. @search-change="searchChange"
  49. @search-reset="searchReset"
  50. @refresh-change="refreshChange"
  51. @selection-change="selectionChange"
  52. @on-load="onLoad"
  53. @tree-load="treeLoad">
  54. </avue-crud>
  55. </basic-container>
  56. </el-col>
  57. </el-row>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button @click="dialogVisible = false">取 消</el-button>
  60. <el-button type="primary" @click="confirmSelection"
  61. :disabled="configuration.multipleChoices === true?false:selection.length === 1?false:true">确 定</el-button>
  62. </span>
  63. </el-dialog>
  64. </span>
  65. </template>
  66. <script>
  67. import option from "./configuration/mainList.json";
  68. import {customerList, typeSave, deleteDetails, getDeptLazyTree} from "@/api/basicData/customerInformation"
  69. export default {
  70. name: "customerInformation",
  71. props: {
  72. disabled: Boolean,
  73. value: String,
  74. configuration: Object,
  75. },
  76. model: {
  77. prop: 'value',
  78. event: 'returnBack'
  79. },
  80. data() {
  81. return {
  82. form: {},
  83. dicData: [],
  84. dialogVisible: false,
  85. value: '',
  86. option: option,
  87. parentId: 0,
  88. dataList: [],
  89. selection: [],
  90. treeOption: {
  91. nodeKey: 'id',
  92. lazy: true,
  93. treeLoad: function (node, resolve) {
  94. const parentId = (node.level === 0) ? 0 : node.data.id;
  95. getDeptLazyTree(parentId).then(res => {
  96. resolve(res.data.data.map(item => {
  97. return {
  98. ...item,
  99. leaf: !item.hasChildren
  100. }
  101. }))
  102. });
  103. },
  104. addBtn: false,
  105. menu: false,
  106. size: 'small',
  107. props: {
  108. labelText: '标题',
  109. label: 'title',
  110. value: 'value',
  111. children: 'children'
  112. }
  113. },
  114. page: {
  115. pageSize: 10,
  116. pagerCount: 5,
  117. total: 0,
  118. }
  119. }
  120. },
  121. created() {
  122. this.option.searchShow = this.configuration.searchShow ? this.configuration.searchShow : false
  123. },
  124. methods: {
  125. //刷新触发
  126. refreshChange() {
  127. this.page = {
  128. pageSize: 10,
  129. pagerCount: 5,
  130. total: 0,
  131. }
  132. },
  133. //确认导出触发
  134. confirmSelection() {
  135. if (this.configuration.multipleChoices === true) {
  136. let value = []
  137. for (let item in this.selection) {
  138. this.dicData.push({id: this.selection[item].id, cname: this.selection[item].cname})
  139. value.push(this.selection[item].id)
  140. }
  141. this.value = value
  142. } else {
  143. this.dicData.push({id: this.selection[0].id, cname: this.selection[0].cname})
  144. this.value = this.selection[0].id
  145. }
  146. this.selection = []
  147. this.$emit('returnBack', this.value)
  148. this.dialogVisible = false
  149. },
  150. //选中触发
  151. selectionChange(selection) {
  152. this.selection = selection
  153. },
  154. nodeClick(data) {
  155. this.treeDeptId = data.id;
  156. this.page.currentPage = 1;
  157. this.onLoad(this.page);
  158. },
  159. //查询全部
  160. initData() {
  161. customerList().then(res => {
  162. console.log(this.form);
  163. const column = this.findObject(this.option.column, "parentId");
  164. column.dicData = res.data.data.records;
  165. });
  166. },
  167. //新增子项触发
  168. handleAdd(row) {
  169. this.parentId = row.id;
  170. const column = this.findObject(this.option.column, "parentId");
  171. column.value = row.id;
  172. column.addDisabled = true;
  173. this.$refs.crud.rowAdd();
  174. },
  175. //新增跳转页面
  176. beforeOpen(row, index) {
  177. this.$router.push({
  178. path: "/detailsPageEdit",
  179. query: {id: JSON.stringify(row.id)},
  180. });
  181. },
  182. //点击新增时触发
  183. beforeClose(done) {
  184. this.parentId = "";
  185. const column = this.findObject(this.option.column, "parentId");
  186. column.value = "";
  187. column.addDisabled = false;
  188. done();
  189. },
  190. //点击搜索按钮触发
  191. searchChange(params, done) {
  192. console.log(params)
  193. this.page.currentPage = 1;
  194. this.onLoad(this.page, params);
  195. done()
  196. },
  197. //搜索重置按钮触发
  198. searchReset() {
  199. this.treeDeptId = '';
  200. this.onLoad(this.page);
  201. },
  202. onLoad(page, params = {parentId: 0}) {
  203. let queryParams = Object.assign({}, params, {
  204. size: page.pageSize,
  205. current: page.currentPage,
  206. corpsTypeId: this.treeDeptId
  207. })
  208. customerList(queryParams).then(res => {
  209. this.dataList = res.data.data.records
  210. console.log(res.data.data.total)
  211. this.page.total = res.data.data.total
  212. console.log(this.page)
  213. })
  214. },
  215. //树桩列点击展开触发
  216. treeLoad(tree, treeNode, resolve) {
  217. const parentId = tree.id;
  218. customerList({parentId: parentId}).then(res => {
  219. resolve(res.data.data.records);
  220. });
  221. }
  222. }
  223. };
  224. </script>
  225. <style scoped lang="scss">
  226. .el-dialogDeep {
  227. ::v-deep .el-dialog {
  228. margin: 1vh auto 0 !important;
  229. padding-bottom: 10px !important;
  230. .el-dialog__body, .el-dialog__footer {
  231. padding-bottom: 0 !important;
  232. padding-top: 0 !important;
  233. }
  234. }
  235. }
  236. </style>