index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. :visible.sync="dialogVisible"
  30. class="el-dialogDeep"
  31. append-to-body
  32. width="80%">
  33. <el-row style="height: 0">
  34. <el-col :span="5">
  35. <div class="box">
  36. <el-scrollbar>
  37. <basic-container>
  38. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  39. </basic-container>
  40. </el-scrollbar>
  41. </div>
  42. </el-col>
  43. <el-col :span="19">
  44. <basic-container>
  45. <avue-crud :option="option"
  46. :data="dataList"
  47. ref="crud"
  48. v-model="form"
  49. :page.sync="page"
  50. :before-close="beforeClose"
  51. @search-change="searchChange"
  52. @search-reset="searchReset"
  53. @refresh-change="refreshChange"
  54. @selection-change="selectionChange"
  55. @on-load="onLoad"
  56. @tree-load="treeLoad">
  57. </avue-crud>
  58. </basic-container>
  59. </el-col>
  60. </el-row>
  61. <span slot="footer" class="dialog-footer">
  62. <el-button @click="dialogVisible = false">取 消</el-button>
  63. <el-button type="primary" @click="confirmSelection"
  64. :disabled="configuration.multipleChoices === true?false:selection.length === 1?false:true">确 定</el-button>
  65. </span>
  66. </el-dialog>
  67. </span>
  68. </template>
  69. <script>
  70. import option from "./configuration/mainList.json";
  71. import {customerList, typeSave,detail,deleteDetails,getDeptLazyTree,getDeptTree} from "@/api/basicData/basicStorageDesc"
  72. // import {customerList, typeSave, deleteDetails, getDeptLazyTree} from "@/api/basicData/customerInformation"
  73. export default {
  74. name: "customerInformation",
  75. props: {
  76. disabled: Boolean,
  77. value: String,
  78. configuration: Object,
  79. },
  80. model: {
  81. prop: 'value',
  82. event: 'returnBack'
  83. },
  84. data() {
  85. return {
  86. form: {},
  87. dicData: [],
  88. dialogVisible: false,
  89. value: '',
  90. option: option,
  91. parentId: 0,
  92. dataList: [],
  93. selection: [],
  94. treeOption: {
  95. nodeKey: 'id',
  96. lazy: true,
  97. treeLoad: function (node, resolve) {
  98. const parentId = (node.level === 0) ? 0 : node.data.id;
  99. getDeptLazyTree(parentId).then(res => {
  100. resolve(res.data.data.map(item => {
  101. return {
  102. ...item,
  103. leaf: !item.hasChildren
  104. }
  105. }))
  106. });
  107. },
  108. addBtn: false,
  109. menu: false,
  110. size: 'small',
  111. props: {
  112. labelText: '标题',
  113. label: 'title',
  114. value: 'value',
  115. children: 'children'
  116. }
  117. },
  118. page: {
  119. pageSize: 10,
  120. pagerCount: 5,
  121. total: 0,
  122. },
  123. // 远程模糊查找loading
  124. loading: false,
  125. queryParams: {
  126. size: 10,
  127. current: 1
  128. },
  129. }
  130. },
  131. created() {
  132. // this.option.searchShow = this.configuration.searchShow ? this.configuration.searchShow : false
  133. this.remoteMethod()
  134. },
  135. methods: {
  136. changeName(){
  137. this.$emit('returnBack', this.value)
  138. },
  139. //刷新触发
  140. refreshChange() {
  141. this.page = {
  142. pageSize: 10,
  143. pagerCount: 5,
  144. total: 0,
  145. }
  146. },
  147. //确认导出触发
  148. confirmSelection() {
  149. this.dicData = []
  150. if (this.configuration.multipleChoices === true) {
  151. let value = []
  152. for (let item in this.selection) {
  153. this.dicData.push({id: this.selection[item].id, cname: this.selection[item].cname})
  154. value.push(this.selection[item].id)
  155. }
  156. this.value = value
  157. } else {
  158. this.dicData.push({id: this.selection[0].id, cname: this.selection[0].cname})
  159. this.value = this.selection[0].id
  160. }
  161. this.selection = []
  162. this.$emit('returnBack', this.value)
  163. this.dialogVisible = false
  164. this.$emit('receiveList',this.dicData)
  165. },
  166. //选中触发
  167. selectionChange(selection) {
  168. this.selection = selection
  169. },
  170. nodeClick(data) {
  171. this.treeDeptId = data.id;
  172. this.page.currentPage = 1;
  173. this.onLoad(this.page);
  174. },
  175. //查询全部
  176. initData() {
  177. customerList().then(res => {
  178. console.log(this.form);
  179. const column = this.findObject(this.option.column, "parentId");
  180. column.dicData = res.data.data.records;
  181. });
  182. },
  183. //新增子项触发
  184. handleAdd(row) {
  185. this.parentId = row.id;
  186. const column = this.findObject(this.option.column, "parentId");
  187. column.value = row.id;
  188. column.addDisabled = true;
  189. this.$refs.crud.rowAdd();
  190. },
  191. //点击新增时触发
  192. beforeClose(done) {
  193. this.parentId = "";
  194. const column = this.findObject(this.option.column, "parentId");
  195. column.value = "";
  196. column.addDisabled = false;
  197. done();
  198. },
  199. //点击搜索按钮触发
  200. searchChange(params, done) {
  201. console.log(params)
  202. this.page.currentPage = 1;
  203. this.onLoad(this.page, params);
  204. done()
  205. },
  206. //搜索重置按钮触发
  207. searchReset() {
  208. this.treeDeptId = '';
  209. this.onLoad(this.page);
  210. },
  211. onLoad(page, params = {parentId: 0}) {
  212. let queryParams = Object.assign({}, params, {
  213. size: page.pageSize,
  214. current: page.currentPage,
  215. corpsTypeId: this.treeDeptId
  216. })
  217. customerList(queryParams).then(res => {
  218. this.dataList = res.data.data.records
  219. this.page.total = res.data.data.total
  220. if (this.page.total) {
  221. this.option.height = window.innerHeight - 500;
  222. } else {
  223. this.option.height = window.innerHeight - 200;
  224. }
  225. })
  226. },
  227. //树桩列点击展开触发
  228. treeLoad(tree, treeNode, resolve) {
  229. const parentId = tree.id;
  230. customerList({parentId: parentId}).then(res => {
  231. resolve(res.data.data.records);
  232. });
  233. },
  234. // 远程模糊查找
  235. remoteMethod(query) {
  236. if (query !== '') {
  237. this.loading = true;
  238. this.queryParams = {
  239. size: 10,
  240. current: 1,
  241. cname: query
  242. }
  243. customerList(this.queryParams).then(res => {
  244. this.dicData = res.data.data.records
  245. this.loading = false;
  246. });
  247. } else {
  248. this.loading = true
  249. this.queryParams = {
  250. size: 10,
  251. current: 1
  252. }
  253. customerList(this.queryParams).then(res => {
  254. this.dicData = res.data.data.records
  255. this.loading = false;
  256. });
  257. }
  258. },
  259. }
  260. };
  261. </script>
  262. <style scoped lang="scss">
  263. .el-dialogDeep {
  264. ::v-deep .el-dialog {
  265. .el-dialog__body, .el-dialog__footer {
  266. padding-bottom: 0 !important;
  267. padding-top: 0 !important;
  268. }
  269. }
  270. }
  271. </style>