cc619bccb9ac3c2f070fedf1cbfdb23cb3af1492.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div>
  3. <el-select
  4. v-model="value"
  5. placeholder="请选择"
  6. filterable
  7. autoComplete = "off"
  8. :filter-method="filterMethod"
  9. @change='chooseChange'
  10. >
  11. <el-option
  12. v-for="item in searchDataList"
  13. :key="item.code"
  14. :value="item.code"
  15. :label="item.townName"
  16. >
  17. <span style="float: left;color:rgba(0,0,0,0.5);font-size:small" v-if="item.value == '无相应乡镇'">*如无相应乡镇</span>
  18. <span style="float: right; color: #8492a6; font-size: 13px" v-if="item.value == '无相应乡镇'">
  19. <el-button type="text" size='mini' plain @click="insertCun">添加乡镇</el-button>
  20. </span>
  21. <span style="float: right; color: #8492a6; font-size: 13px">{{ item.townName }}</span>
  22. </el-option>
  23. </el-select>
  24. <el-dialog
  25. title="添加乡镇"
  26. :visible.sync="dialogVisible"
  27. width="30%"
  28. :modal="false"
  29. >
  30. <el-form :model="newCunForm" label-width="120px">
  31. <p style="margin-top:10px;margin-bottom: 10px"><i class="el-icon-caret-right"></i><span style="width:120px;padding-left: 10px">行政村基本信息</span><span class="hrs"></span></p>
  32. <el-form-item label="行政乡镇名称">
  33. <el-input v-model="newCunForm.adName" style="width:70%;"></el-input>
  34. </el-form-item>
  35. <el-form-item label="操作">
  36. <el-button @click="dialogVisible = false">取 消</el-button>
  37. <el-button type="primary" @click="submitInsertCun">确 定</el-button>
  38. </el-form-item>
  39. </el-form>
  40. </el-dialog>
  41. </div>
  42. </template>
  43. <script>
  44. import { getVillageList_ny ,submitInsertCun} from "../api/duChaTianBao.js";
  45. export default {
  46. props: ['rootCode','initalValue'],
  47. data() {
  48. return {
  49. dataList: [],
  50. value: '',
  51. dialogVisible:false,
  52. searchDataList:[],
  53. timeout: null,
  54. xianlistData:[],
  55. newCunForm:{
  56. "adAbbrName": "",
  57. "adFcode": "",
  58. "adFullName": "",
  59. "adName": "",
  60. },
  61. }
  62. },
  63. computed:{
  64. },
  65. mounted(){
  66. this.value = this.initalValue;
  67. console.log(this.value);
  68. this.querySearchAsync();
  69. },
  70. watch: {
  71. rootCode:function(){
  72. this.querySearchAsync();
  73. },
  74. initalValue:function(){
  75. this.value = this.initalValue;
  76. console.log(this.value);
  77. this.querySearchAsync();
  78. }
  79. },
  80. methods:{
  81. submitInsertCun:function(){
  82. submitInsertCun(this.newCunForm.adName,this.rootCode).then(
  83. (res) => {
  84. console.log(res);
  85. this.querySearchAsync();
  86. this. newCunForm={
  87. "adAbbrName": "",
  88. "adFcode": "",
  89. "adFullName": "",
  90. "adName": "",
  91. };
  92. this.dialogVisible = false;
  93. }
  94. );
  95. },
  96. insertCun:function(){
  97. this.dialogVisible = true;
  98. },
  99. chooseChange:function(p){
  100. console.log(p);
  101. this.dataList.forEach((element) => {
  102. if(element.code == p){
  103. console.log(element);
  104. this.$emit("provTreeSelectChange", { 'code':element.code, 'name': element.townName});
  105. }
  106. });
  107. },
  108. filterMethod:function(text){
  109. console.log(text);
  110. this.value = text;
  111. let filterResult = [{
  112. 'value':'无相应乡镇',
  113. 'label':'添加'
  114. }];
  115. this.dataList.forEach((element) =>{
  116. if(element.townName.indexOf(text)>=0 || element.townName.indexOf(text)>=0){
  117. filterResult.push(element);
  118. }
  119. });
  120. this.searchDataList = filterResult;
  121. },
  122. querySearchAsync() {
  123. // cb(results);
  124. getVillageList_ny(this.rootCode).then((res) =>{
  125. console.log(res);
  126. var children = [];
  127. let lists = [];
  128. res.data.list.forEach((element,index)=>{
  129. lists.push({'value':element.townCode,
  130. 'townName':element.townName,
  131. 'label':element.townName,'code':element.townCode});
  132. });
  133. this.dataList = lists;
  134. this.searchDataList = lists;
  135. console.log(this.xianlistData);
  136. },(err) =>{});
  137. },
  138. },
  139. }
  140. </script>
  141. <style>
  142. </style>