costBreakdown.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. :close-on-click-modal="false"
  33. append-to-body
  34. width="70%">
  35. <template slot="title">
  36. <span class="el-dialog__title">
  37. <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
  38. 导入费用
  39. </span>
  40. <div style="float: right" class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  41. <i class="el-icon-full-screen"></i>
  42. </div>
  43. </template>
  44. <el-row style="height: 0">
  45. <el-col :span="5">
  46. <div class="box">
  47. <el-scrollbar>
  48. <basic-container>
  49. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  50. </basic-container>
  51. </el-scrollbar>
  52. </div>
  53. </el-col>
  54. <el-col :span="19">
  55. <basic-container>
  56. <avue-crud :option="option"
  57. :data="dataList"
  58. ref="crud"
  59. v-model="form"
  60. :page.sync="page"
  61. :before-close="beforeClose"
  62. @search-change="searchChange"
  63. @search-reset="searchReset"
  64. @refresh-change="refreshChange"
  65. @selection-change="selectionChange"
  66. @on-load="onLoad"
  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 "./config/feeList.json";
  82. import { getDeptLazyTree, customerList } from "@/api/basicData/basicFeesDesc";
  83. export default {
  84. name: "costBreakdown",
  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: 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. created() {
  143. // this.option.searchShow = this.configuration.searchShow ? this.configuration.searchShow : false
  144. this.remoteMethod()
  145. },
  146. methods: {
  147. changeName(){
  148. this.$emit('returnBack', this.value)
  149. let optionList = this.configuration.dicData.length !== 0?this.dicData.length !== 0?this.dicData:this.configuration.dicData:this.dicData;
  150. let selectValue ;
  151. optionList.map(item =>{
  152. if(item.id === this.value){
  153. selectValue = {
  154. id : item.id,
  155. cname:item.cname,
  156. ename:item.ename,
  157. unitno : item.unitno,
  158. fcyno:item.fcyno
  159. }
  160. }
  161. })
  162. this.$emit('selectValue',selectValue)
  163. },
  164. //刷新触发
  165. refreshChange() {
  166. this.page = {
  167. pageSize: 10,
  168. pagerCount: 5,
  169. total: 0,
  170. }
  171. },
  172. //确认导出触发
  173. confirmSelection() {
  174. this.dicData = []
  175. if (this.configuration.multipleChoices === true) {
  176. let value = []
  177. for (let item in this.selection) {
  178. this.dicData.push({id: this.selection[item].id, cname: this.selection[item].cname})
  179. value.push(this.selection[item].id)
  180. }
  181. this.value = value
  182. } else {
  183. this.dicData.push({id: this.selection[0].id, cname: this.selection[0].cname})
  184. this.value = this.selection[0].id
  185. }
  186. let selectValue = {
  187. id : this.selection[0].id,
  188. cname : this.selection[0].cname,
  189. unitno : this.selection[0].unitno,
  190. fcyno: this.selection[0].fcyno,
  191. } ;
  192. this.$emit('selectValue',selectValue)
  193. this.selection = []
  194. this.$emit('returnBack', this.value)
  195. this.dialogVisible = false
  196. this.$emit('receiveList',this.dicData)
  197. },
  198. //选中触发
  199. selectionChange(selection) {
  200. this.selection = selection
  201. },
  202. nodeClick(data) {
  203. this.treeDeptId = data.id;
  204. this.page.currentPage = 1;
  205. this.onLoad(this.page);
  206. },
  207. //查询全部
  208. initData() {
  209. customerList().then(res => {
  210. const column = this.findObject(this.option.column, "parentId");
  211. column.dicData = res.data.data.records;
  212. });
  213. },
  214. //新增子项触发
  215. handleAdd(row) {
  216. this.parentId = row.id;
  217. const column = this.findObject(this.option.column, "parentId");
  218. column.value = row.id;
  219. column.addDisabled = true;
  220. this.$refs.crud.rowAdd();
  221. },
  222. //点击新增时触发
  223. beforeClose(done) {
  224. this.parentId = "";
  225. const column = this.findObject(this.option.column, "parentId");
  226. column.value = "";
  227. column.addDisabled = false;
  228. done();
  229. },
  230. //点击搜索按钮触发
  231. searchChange(params, done) {
  232. this.page.currentPage = 1;
  233. this.onLoad(this.page, params);
  234. done()
  235. },
  236. //搜索重置按钮触发
  237. searchReset() {
  238. this.treeDeptId = '';
  239. this.onLoad(this.page);
  240. },
  241. onLoad(page, params = {parentId: 0}) {
  242. let queryParams = Object.assign({}, params, {
  243. size: page.pageSize,
  244. current: page.currentPage,
  245. feesTypeId: this.treeDeptId
  246. })
  247. customerList(queryParams).then(res => {
  248. this.dataList = res.data.data.records
  249. this.page.total = res.data.data.total
  250. if (this.page.total) {
  251. this.option.height = window.innerHeight - 500;
  252. } else {
  253. this.option.height = window.innerHeight - 200;
  254. }
  255. })
  256. },
  257. //树桩列点击展开触发
  258. treeLoad(tree, treeNode, resolve) {
  259. const parentId = tree.id;
  260. customerList({parentId: parentId}).then(res => {
  261. resolve(res.data.data.records);
  262. });
  263. },
  264. // 远程模糊查找
  265. remoteMethod(query) {
  266. if (query) {
  267. this.loading = true;
  268. this.queryParams = {
  269. size: 10,
  270. current: 1,
  271. cname: query
  272. }
  273. customerList(this.queryParams).then(res => {
  274. this.dicData = res.data.data.records
  275. this.loading = false;
  276. });
  277. } else {
  278. this.loading = true
  279. this.queryParams = {
  280. size: 10,
  281. current: 1
  282. }
  283. customerList(this.queryParams).then(res => {
  284. this.dicData = []
  285. this.configuration.dicData = this.configuration.dicData.concat(res.data.data.records)
  286. // this.configuration.dicData = res.data.data.records
  287. this.removeRepeat()
  288. this.loading = false;
  289. });
  290. }
  291. },
  292. // 去重
  293. removeRepeat() {
  294. let obj = []
  295. this.configuration.dicData = this.configuration.dicData.reduce((current,next) => {
  296. obj[next.id] ? '': obj[next.id] = true && current.push(next)
  297. return current
  298. }, [])
  299. },
  300. }
  301. };
  302. </script>
  303. <style scoped lang="scss">
  304. .el-dialogDeep {
  305. ::v-deep .el-dialog {
  306. .el-dialog__body, .el-dialog__footer {
  307. padding-bottom: 0 !important;
  308. padding-top: 0 !important;
  309. }
  310. }
  311. }
  312. </style>