costBreakdown.vue 9.5 KB

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