index.vue 8.6 KB

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