index.vue 8.5 KB

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