e008b6450f992d16593d5b2b7adb48448671163a.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div class="nygs">
  3. <el-container style="height:520px;">
  4. <el-main style="border:1px solid #d5d5ff;margin-left:5px;padding:0;overflow:hidden">
  5. <el-card class="box-card" style="height:255px;">
  6. <div slot="header" class="clearfix">
  7. <span>村</span>
  8. <el-button style="float: right; padding: 3px 0" type="text" @click="addXzc" v-if="openType">添加行政村</el-button>
  9. </div>
  10. <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClickXzc"
  11. node-key="id"
  12. class="left_tree"
  13. :expand-on-click-node="false">
  14. <span class="custom-tree-node" slot-scope="{ node, data }">
  15. <span>{{ node.label }}</span>
  16. <span>
  17. <el-button
  18. type="text"
  19. size="mini"
  20. v-if="data.children"
  21. @click.stop="() => addN(data,node)">
  22. 添加自然村
  23. </el-button>
  24. <el-button
  25. type="text"
  26. size="mini"
  27. @click.stop="() => removeNode(data,node)">
  28. 删除
  29. </el-button>
  30. </span>
  31. </span>
  32. </el-tree>
  33. </el-card>
  34. <el-card class="box-card mt20" style="height:255px;">
  35. <div slot="header" class="clearfix">
  36. <span>供水单位</span>
  37. <el-button style="float: right; padding: 3px 0" type="text" @click="addGsdw" v-if="openType">添加</el-button>
  38. </div>
  39. <ul class="ul_height">
  40. <li v-for="(item,index) in gsdwList" :key="index" class="text item lh40">
  41. <p @click="gsdwRow(item)">
  42. {{ item.nm }}
  43. <span class="flr">
  44. <el-button
  45. type="text"
  46. size="mini"
  47. @click.stop="() => gsdwDelete(item)">
  48. 删除
  49. </el-button>
  50. </span>
  51. </p>
  52. </li>
  53. </ul>
  54. <el-pagination
  55. small
  56. layout="prev, pager, next"
  57. :current-page="pageNum"
  58. :page-size="pageSize"
  59. :total="total"
  60. @current-change="pageIndexChange"
  61. @size-change="handleSizeChange">
  62. </el-pagination>
  63. </el-card>
  64. </el-main>
  65. </el-container>
  66. <el-dialog
  67. class="outerDialog custom_dialog"
  68. :title="anTitle"
  69. width="40%"
  70. :visible.sync="anVisible"
  71. :close-on-click-modal="false"
  72. :modal-append-to-body="true"
  73. :append-to-body="true">
  74. <el-form :model="anForm" ref="anForm" label-width="200px">
  75. <el-form-item label="名称">
  76. <el-input type="text" v-model="anForm.nm" clearable placeholder="请输入村名" style="width:60%;"></el-input>
  77. </el-form-item>
  78. <el-form-item label="地点">
  79. <el-input type="text" v-model="anForm.loc" clearable placeholder="请输入地点" style="width:60%;"></el-input>
  80. </el-form-item>
  81. </el-form>
  82. <span slot="footer">
  83. <el-button style="margin-top:5px;" @click="saveAn">确定</el-button>
  84. </span>
  85. </el-dialog>
  86. <el-dialog
  87. class="outerDialog custom_dialog"
  88. title="添加供水工程"
  89. width="40%"
  90. :visible.sync="gcVisible"
  91. :close-on-click-modal="false"
  92. :modal-append-to-body="true"
  93. :append-to-body="true">
  94. <el-form :model="gcForm" ref="gcForm" label-width="200px">
  95. <el-form-item label="供水工程名称">
  96. <el-input type="text" v-model="gcForm.nm" clearable placeholder="请输入供水工程名称" style="width:60%;"></el-input>
  97. </el-form-item>
  98. <el-form-item label="供水工程规模">
  99. <el-select v-model="gcForm.designWaterSupply" clearable placeholder="请选择">
  100. <el-option label="万人工程" value="1"></el-option>
  101. <el-option label="千人工程" value="2"></el-option>
  102. <el-option label="千人以下集中供水工程" value="3"></el-option>
  103. </el-select>
  104. </el-form-item>
  105. <el-form-item label="地点">
  106. <el-input type="text" v-model="gcForm.loc" clearable placeholder="请输入地点" style="width:60%;"></el-input>
  107. </el-form-item>
  108. <el-form-item label="运行管理单位名称">
  109. <el-input type="text" v-model="gcForm.runDep" clearable placeholder="请输入运行管理单位名称" style="width:60%;"></el-input>
  110. </el-form-item>
  111. <el-form-item label="管理人员数量">
  112. <el-input type="text" v-model="gcForm.mngSize" clearable placeholder="请输入管理人员数量" style="width:60%;"></el-input>
  113. </el-form-item>
  114. </el-form>
  115. <span slot="footer">
  116. <el-button style="margin-top:5px;" @click="saveGC">确定</el-button>
  117. </span>
  118. </el-dialog>
  119. <villT @closeDialogVill="closeDialogVill" v-if="isVisibleVillT" :currentVillDTitle="currentVillDTitle" :currentVillTitle="currentVillTitle" :currentVillId="currentVillId" :currentObjectId="currentObjectId" :currentObjectName="currentObjectName" :currentObjectRgstrId="currentObjectRgstrId" :rowData="rowData" :openType="openType"></villT>
  120. <gcTab @closeDialogGc="closeDialogGc" v-if="isVisibleGc" :currentGcTitle="currentGcTitle" :currentGcId="currentGcId" :currentObjectId="currentObjectId" :currentObjectName="currentObjectName" :currentObjectRgstrId="currentObjectRgstrId" :rowData="rowData" :openType="openType"></gcTab>
  121. </div>
  122. </template>
  123. <script>
  124. import inputWith from "@widget/inuptWith.vue"
  125. import request from "@util/gw_ajax_request.js"
  126. import villT from "./villT"
  127. import gcTab from "./gcTab"
  128. export default {
  129. components: {
  130. inputWith: inputWith,
  131. villT:villT,
  132. gcTab:gcTab
  133. },
  134. props: ['currentObjectId', 'currentObjectName', 'currentObjectRgstrId', 'rowData','openType'],
  135. data() {
  136. return {
  137. treeData: [],
  138. defaultProps: {
  139. children: 'children',
  140. label: 'nm'
  141. },
  142. anVisible:false,
  143. anTitle:"",
  144. villId:"",
  145. currentVillId:"",
  146. currentVillTitle:"",
  147. currentVillDTitle:"",
  148. currentGcId:"",
  149. currentGcTitle:"",
  150. currRow:{},
  151. anForm:{
  152. nm:"",
  153. loc:""
  154. },
  155. gsdwList:[],
  156. total:0,
  157. pageSize:5,
  158. pageNum:1,
  159. gcVisible:false,
  160. gcForm:{
  161. nm:"",
  162. designWaterSupply:"",
  163. loc:"",
  164. runDep:"",
  165. mngSize:""
  166. },
  167. isVisibleVillT:false,
  168. isVisibleGc:false,
  169. }
  170. },
  171. computed: {
  172. recPersId() {
  173. return localStorage.getItem("userid") ? localStorage.getItem("userid") : ''
  174. }
  175. },
  176. created() {
  177. },
  178. mounted() {
  179. this.getLeftTreeData();
  180. this.getGsdwList();
  181. },
  182. watch: {
  183. },
  184. methods: {
  185. gsdwRow(row){
  186. this.currentGcId = row.id;
  187. this.currentGcTitle = row.nm;
  188. this.isVisibleGc = true;
  189. },
  190. closeDialogVill(){
  191. this.isVisibleVillT = false;
  192. },
  193. closeDialogGc(){
  194. this.isVisibleGc = false;
  195. },
  196. addGsdw(){
  197. this.gcVisible = true;
  198. },
  199. saveGC(){
  200. var _self = this;
  201. var obj = this.gcForm;
  202. obj.rgstrId = this.rowData.rgstrId;
  203. request.post("/bis/insp/villgd/wtsp",this.gcForm).then(res => {
  204. if (res.success) {
  205. _self.gcForm = {};
  206. _self.gcVisible = false;
  207. _self.getGsdwList();
  208. }
  209. })
  210. },
  211. pageIndexChange(val){
  212. this.pageNum = val;
  213. this.getGsdwList();
  214. },
  215. handleSizeChange(val){
  216. this.pageSize = val;
  217. this.getGsdwList();
  218. },
  219. handleNodeClickXzc(node, data) {
  220. if(node.children){
  221. this.currentVillTitle = "行政村"
  222. }else{
  223. this.currentVillTitle = "自然村"
  224. }
  225. this.currentVillDTitle = node.nm;
  226. this.isVisibleVillT = true;
  227. this.currentVillId = node.id;
  228. },
  229. removeNode(row,node){
  230. var _self = this;
  231. var url = "";
  232. if(row.children){
  233. url = "/bis/insp/villgd/vill/delete/"+row.id;
  234. }else{
  235. url = "/bis/insp/villgd/nvill/delete/"+row.id;
  236. }
  237. request.post(url).then(res => {
  238. if (res.success) {
  239. const parent = node.parent;
  240. const children = parent.data.children || parent.data;
  241. const index = children.findIndex(d => d.id === row.id);
  242. children.splice(index, 1);
  243. }
  244. })
  245. },
  246. saveAn(){
  247. var _self = this;
  248. var obj = this.anForm;
  249. obj.rgstrId = this.rowData.rgstrId;
  250. var url = "";
  251. if(this.villId){
  252. url = "/bis/insp/villgd/nvill"
  253. obj.villId = this.villId;
  254. }else{
  255. url = "/bis/insp/villgd/vill"
  256. }
  257. request.post(url, obj).then(res => {
  258. if (res.success) {
  259. _self.anVisible = false;
  260. _self.anForm = {nm:"", loc:""};
  261. if(this.villId){
  262. const newChild = { id: res.data.id,nm:res.data.nm,loc:res.data.loc};
  263. this.currRow.children.push(newChild);
  264. }else{
  265. const newChild = { id: res.data.id,nm:res.data.nm,loc:res.data.loc,children: []};
  266. _self.treeData.push(newChild);
  267. }
  268. }
  269. })
  270. },
  271. addXzc(){
  272. this.currRow = {};
  273. this.villId = "";
  274. this.anTitle = "添加行政村";
  275. this.anVisible = true;
  276. },
  277. addN(row,node){
  278. this.currRow = row;
  279. this.villId = row.id;
  280. this.anTitle = "添加自然村";
  281. this.anVisible = true;
  282. },
  283. //左侧树数据
  284. getLeftTreeData() {
  285. var _self = this;
  286. request.get(`/bis/insp/villgd/getVillTree/${this.rowData.rgstrId}`)
  287. .then(res => {
  288. if (res.success && res.data) {
  289. if(res.data instanceof Array){
  290. _self.treeData = res.data;
  291. }else{
  292. _self.treeData = [];
  293. }
  294. }
  295. })
  296. },
  297. getGsdwList(){
  298. var _self = this;
  299. var obj = {
  300. rgstrId: this.rowData.rgstrId,
  301. pageNum:this.pageNum,
  302. pageSize:this.pageSize
  303. }
  304. request.post(`/bis/insp/villgd/wtsp/listOfPage`,obj).then(res => {
  305. if (res.success) {
  306. _self.gsdwList = res.data.list;
  307. _self.total = res.data.total;
  308. }
  309. })
  310. },
  311. //供水单位删除
  312. gsdwDelete(row) {
  313. this.$confirm('确定要删除该数据, 是否继续?', '提示', {
  314. confirmButtonText: '确定',
  315. cancelButtonText: '取消',
  316. type: 'warning'
  317. }).then(() => {
  318. request.post(`/bis/insp/villgd/wtsp/delete/${row.id}`)
  319. .then(res => {
  320. if (res.success) {
  321. this.$message.success("删除成功");
  322. this.getGsdwList();
  323. } else {
  324. this.$message.warning(res.message);
  325. }
  326. })
  327. .catch(err => {
  328. console.log(err);
  329. })
  330. }).catch(() => {
  331. this.$message({
  332. type: 'info',
  333. message: '已取消删除'
  334. });
  335. });
  336. }
  337. }
  338. }
  339. </script>
  340. <style scoped>
  341. .nygs >>> .el-card__body{
  342. padding: 5px;
  343. }
  344. </style>
  345. <style lang="scss">
  346. /*.nygs{*/
  347. .aside_title {
  348. padding-right: 10px;
  349. height: 30px;
  350. line-height: 30px;
  351. text-align: end;
  352. border-bottom: 1px solid rgb(235, 238, 245);
  353. background-color: #d5d5ff;
  354. }
  355. .village_title {
  356. text-align: center;
  357. }
  358. .ul_height {
  359. height: 160px;
  360. overflow: auto;
  361. }
  362. .box-card {
  363. /*height: 200px;*/
  364. overflow: auto;
  365. }
  366. /*.mt20{*/
  367. /*margin-top: 20px;*/
  368. /*}*/
  369. .lh40 {
  370. list-style: none;
  371. height: 40px;
  372. line-height: 40px;
  373. cursor: pointer;
  374. padding: 0 10px;
  375. border-bottom: 1px solid rgb(235, 238, 245);
  376. }
  377. .flr {
  378. float: right;
  379. margin-right: 20px;
  380. }
  381. .nygs span.custom-tree-node {
  382. width: 100%;
  383. }
  384. .mr10 {
  385. margin-right: 20px;
  386. float: right;
  387. }
  388. .nygs .el-tree-node__content {
  389. height: 40px;
  390. line-height: 40px;
  391. }
  392. .nygs .el-tree > div > div:first-child .mr10 {
  393. display: none;
  394. }
  395. .nygs .el-tree-node.is-current > .el-tree-node__content {
  396. background-color: gainsboro !important;
  397. }
  398. .left_tree .custom-tree-node {
  399. flex: 1;
  400. display: flex;
  401. align-items: center;
  402. justify-content: space-between;
  403. font-size: 14px;
  404. padding-right: 8px;
  405. }
  406. /*}*/
  407. </style>