customerSelect.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <span class="select-component" style="display:inline-flex;width: 100%;">
  3. <el-select
  4. v-model="value"
  5. size="small"
  6. :placeholder="configuration.placeholder"
  7. style="border-right: none;width: 100%"
  8. :disabled="disabled?disabled:false"
  9. :multiple="configuration.multiple?configuration.multiple:false"
  10. :clearable="configuration.clearable?configuration.clearable:false"
  11. :collapse-tags="configuration.collapseTags?configuration.collapseTags:false"
  12. filterable
  13. remote
  14. @change="changeName"
  15. :remote-method="remoteMethod"
  16. >
  17. <el-option
  18. v-for="item in configuration.dicData.length !== 0?dicData.length !== 0?dicData:configuration.dicData:dicData"
  19. :key="item.id"
  20. :label="item.cname"
  21. :value="item.id"
  22. />
  23. </el-select>
  24. <el-button slot="append" icon="el-icon-search" size="mini" @click="dialogVisible = true"
  25. :disabled="disabled?disabled:false"></el-button>
  26. <el-dialog
  27. v-dialogdrag
  28. title="导入客户"
  29. :fullscreen="dialogFull"
  30. :visible.sync="dialogVisible"
  31. class="el-dialogDeep"
  32. append-to-body
  33. width="80%">
  34. <template slot="title">
  35. <span class="el-dialog__title">
  36. <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
  37. 导入客户
  38. </span>
  39. <div style="float: right" class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  40. <i class="el-icon-full-screen"></i>
  41. </div>
  42. </template>
  43. <el-row style="height: 0">
  44. <el-col :span="5">
  45. <div class="box">
  46. <el-scrollbar>
  47. <basic-container>
  48. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  49. </basic-container>
  50. </el-scrollbar>
  51. </div>
  52. </el-col>
  53. <el-col :span="19">
  54. <basic-container>
  55. <avue-crud :option="option"
  56. :data="dataList"
  57. ref="crud"
  58. v-model="form"
  59. :page.sync="page"
  60. :before-close="beforeClose"
  61. @search-change="searchChange"
  62. @search-reset="searchReset"
  63. @refresh-change="refreshChange"
  64. @selection-change="selectionChange"
  65. @on-load="onLoad"
  66. @saveColumn="saveColumn"
  67. @tree-load="treeLoad">
  68. </avue-crud>
  69. </basic-container>
  70. </el-col>
  71. </el-row>
  72. <span slot="footer" class="dialog-footer">
  73. <el-button @click="dialogVisible = false">取 消</el-button>
  74. <el-button type="primary" @click="confirmSelection"
  75. :disabled="configuration.multipleChoices === true?false:selection.length === 1?false:true">确 定</el-button>
  76. </span>
  77. </el-dialog>
  78. </span>
  79. </template>
  80. <script>
  81. import option from "./configuration/mainList.json";
  82. import {customerList, typeSave, deleteDetails, getDeptLazyTree} from "@/api/basicData/customerInformation"
  83. export default {
  84. name: "customerInformation",
  85. props: {
  86. disabled: Boolean,
  87. value: String,
  88. configuration: Object,
  89. },
  90. model: {
  91. prop: 'value',
  92. event: 'returnBack'
  93. },
  94. data() {
  95. return {
  96. dialogFull: false,
  97. form: {},
  98. dicData: [],
  99. dialogVisible: false,
  100. value: '',
  101. option: {},
  102. parentId: 0,
  103. dataList: [],
  104. selection: [],
  105. treeOption: {
  106. nodeKey: 'id',
  107. lazy: true,
  108. treeLoad: function (node, resolve) {
  109. const parentId = (node.level === 0) ? 0 : node.data.id;
  110. getDeptLazyTree(parentId).then(res => {
  111. resolve(res.data.data.map(item => {
  112. return {
  113. ...item,
  114. leaf: !item.hasChildren
  115. }
  116. }))
  117. });
  118. },
  119. addBtn: false,
  120. menu: false,
  121. size: 'small',
  122. props: {
  123. labelText: '标题',
  124. label: 'title',
  125. value: 'value',
  126. children: 'children'
  127. }
  128. },
  129. page: {
  130. pageSize: 10,
  131. pagerCount: 5,
  132. total: 0,
  133. },
  134. // 远程模糊查找loading
  135. loading: false,
  136. queryParams: {
  137. size: 10,
  138. current: 1
  139. },
  140. }
  141. },
  142. async created() {
  143. this.option = option
  144. // this.option = await this.getColumnData(this.getColumnName(47), option);
  145. // this.option.searchShow = this.configuration.searchShow ? this.configuration.searchShow : false
  146. this.remoteMethod()
  147. },
  148. methods: {
  149. changeName(){
  150. this.$emit('returnBack', this.value)
  151. },
  152. //刷新触发
  153. refreshChange() {
  154. this.page = {
  155. pageSize: 10,
  156. pagerCount: 5,
  157. total: 0,
  158. }
  159. },
  160. //确认导出触发
  161. confirmSelection() {
  162. this.dicData = []
  163. if (this.configuration.multipleChoices === true) {
  164. let value = []
  165. for (let item in this.selection) {
  166. this.dicData.push({id: this.selection[item].id, cname: this.selection[item].cname})
  167. value.push(this.selection[item].id)
  168. }
  169. this.value = value
  170. } else {
  171. this.dicData.push({id: this.selection[0].id, cname: this.selection[0].cname})
  172. this.value = this.selection[0].id
  173. }
  174. this.selection = []
  175. this.$emit('returnBack', this.value)
  176. this.dialogVisible = false
  177. this.$emit('receiveList',this.dicData)
  178. },
  179. //选中触发
  180. selectionChange(selection) {
  181. this.selection = selection
  182. },
  183. nodeClick(data) {
  184. this.treeDeptId = data.id;
  185. this.page.currentPage = 1;
  186. this.onLoad(this.page);
  187. },
  188. //查询全部
  189. initData() {
  190. customerList().then(res => {
  191. console.log(this.form);
  192. const column = this.findObject(this.option.column, "parentId");
  193. column.dicData = res.data.data.records;
  194. });
  195. },
  196. //新增子项触发
  197. handleAdd(row) {
  198. this.parentId = row.id;
  199. const column = this.findObject(this.option.column, "parentId");
  200. column.value = row.id;
  201. column.addDisabled = true;
  202. this.$refs.crud.rowAdd();
  203. },
  204. //点击新增时触发
  205. beforeClose(done) {
  206. this.parentId = "";
  207. const column = this.findObject(this.option.column, "parentId");
  208. column.value = "";
  209. column.addDisabled = false;
  210. done();
  211. },
  212. //点击搜索按钮触发
  213. searchChange(params, done) {
  214. console.log(params)
  215. this.page.currentPage = 1;
  216. this.onLoad(this.page, params);
  217. done()
  218. },
  219. //搜索重置按钮触发
  220. searchReset() {
  221. this.treeDeptId = '';
  222. this.onLoad(this.page);
  223. },
  224. onLoad(page, params = {parentId: 0}) {
  225. let queryParams = Object.assign({}, params, {
  226. size: page.pageSize,
  227. current: page.currentPage,
  228. corpsTypeId: this.treeDeptId
  229. })
  230. customerList(queryParams).then(res => {
  231. this.dataList = res.data.data.records
  232. this.page.total = res.data.data.total
  233. if (this.page.total) {
  234. this.option.height = window.innerHeight - 500;
  235. } else {
  236. this.option.height = window.innerHeight - 200;
  237. }
  238. })
  239. },
  240. //树桩列点击展开触发
  241. treeLoad(tree, treeNode, resolve) {
  242. const parentId = tree.id;
  243. customerList({parentId: parentId}).then(res => {
  244. resolve(res.data.data.records);
  245. });
  246. },
  247. // 远程模糊查找
  248. remoteMethod(query) {
  249. if (query) {
  250. this.loading = true;
  251. this.queryParams = {
  252. size: 10,
  253. current: 1,
  254. cname: query
  255. }
  256. customerList(this.queryParams).then(res => {
  257. this.dicData = res.data.data.records
  258. this.loading = false;
  259. });
  260. } else {
  261. this.loading = true
  262. this.queryParams = {
  263. size: 10,
  264. current: 1
  265. }
  266. customerList(this.queryParams).then(res => {
  267. this.dicData = []
  268. this.configuration.dicData = this.configuration.dicData.concat(res.data.data.records)
  269. // this.configuration.dicData = res.data.data.records
  270. this.removeRepeat()
  271. this.loading = false;
  272. });
  273. }
  274. },
  275. // 去重
  276. removeRepeat() {
  277. let obj = []
  278. this.configuration.dicData = this.configuration.dicData.reduce((current,next) => {
  279. obj[next.id] ? '': obj[next.id] = true && current.push(next)
  280. return current
  281. }, [])
  282. },
  283. //列保存触发
  284. async saveColumn() {
  285. const inSave = await this.saveColumnData(
  286. this.getColumnName(47),
  287. this.option
  288. );
  289. if (inSave) {
  290. this.$message.success("保存成功");
  291. //关闭窗口
  292. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  293. }
  294. },
  295. }
  296. };
  297. </script>
  298. <style scoped lang="scss">
  299. .el-dialogDeep {
  300. ::v-deep .el-dialog {
  301. .el-dialog__body, .el-dialog__footer {
  302. padding-bottom: 0 !important;
  303. padding-top: 0 !important;
  304. }
  305. }
  306. }
  307. </style>