1e574c4ce8e0844e50902707e33c03e1a8cadf27.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <el-container>
  3. <div class="main-item">
  4. <el-card class="box-card">
  5. <div slot="header" class="clearfix">
  6. <span>二级管理单位</span>
  7. <el-button
  8. @click="toAddUnitTwo"
  9. style="float: right; padding: 3px 0"
  10. type="text"
  11. v-if="ownPriv('manage')"
  12. >添加二级单位</el-button>
  13. </div>
  14. <el-table
  15. :data="unitTwoList"
  16. border
  17. stripe
  18. highlight-current-row
  19. @current-change="handleCurrentChange_unitTwo"
  20. :height="tableHeight"
  21. style="width: 100%">
  22. <el-table-column prop="nm" label="单位名称" min-width="120"></el-table-column>
  23. <el-table-column fixed="right" label="操作" min-width="100">
  24. <template slot-scope="scope">
  25. <el-button @click="toEditUnitTwo(scope.row)" icon="el-icon-edit" type="text" v-if="ownPriv('manage')"></el-button>
  26. <el-button @click="delete_unitTwo(scope.row)" icon="el-icon-delete" type="text" v-if="ownPriv('manage')"></el-button>
  27. <el-button @click="showProblem(scope.row,'二级管理单位')" icon="el-icon-tickets" type="text"></el-button>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. </el-card>
  32. </div>
  33. <div class="main-item">
  34. <el-card class="box-card">
  35. <div slot="header" class="clearfix">
  36. <span>三级管理单位</span>
  37. <el-button
  38. @click="toAddUnitThree"
  39. style="float: right; padding: 3px 0"
  40. type="text"
  41. >添加三级单位</el-button>
  42. </div>
  43. <el-table :data="unitThreeList" border stripe :height="tableHeight" style="width: 100%">
  44. <el-table-column prop="nm" label="单位名称" min-width="100"></el-table-column>
  45. <el-table-column prop="pidName" label="所属二级单位" min-width="100"></el-table-column>
  46. <el-table-column fixed="right" label="操作" min-width="100">
  47. <template slot-scope="scope">
  48. <el-button @click="toEditUnitThree(scope.row)" icon="el-icon-edit" type="text" v-if="ownPriv('manage')"></el-button>
  49. <el-button
  50. @click="delete_unitThree(scope.row)"
  51. icon="el-icon-delete"
  52. type="text"
  53. v-if="ownPriv('manage')"
  54. ></el-button>
  55. <el-button @click="showProblem(scope.row,'三级管理单位')" icon="el-icon-tickets" type="text"></el-button>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. </el-card>
  60. </div>
  61. <!-- 添加/编辑二级管理单位 -->
  62. <el-dialog :title="dialogType + '二级管理单位'" :visible.sync="unitTwo_Dialog">
  63. <el-form label-width="120px">
  64. <el-form-item label="二级单位名称" required>
  65. <el-input v-model="unitTwo.nm" clearable></el-input>
  66. </el-form-item>
  67. </el-form>
  68. <div slot="footer" class="dialog-footer">
  69. <el-button @click="unitTwo_Dialog = false">取 消</el-button>
  70. <el-button type="primary" @click="add_unitTwo">确 定</el-button>
  71. </div>
  72. </el-dialog>
  73. <!-- 添加/编辑三级管理单位 -->
  74. <el-dialog :title="dialogType + '三级管理单位'" :visible.sync="unitThree_Dialog">
  75. <el-form label-width="120px">
  76. <el-form-item label="三级单位名称" required>
  77. <el-input v-model="unitThree.nm" clearable></el-input>
  78. </el-form-item>
  79. <!-- <el-form-item label="所属二级单位" required>
  80. <el-select v-model="unitThree.pid" placeholder="请选择">
  81. <el-option
  82. :label="item.nm"
  83. :value="item.id"
  84. v-for="(item,index) in unitTwoList"
  85. :key="index"
  86. ></el-option>
  87. </el-select>
  88. </el-form-item> -->
  89. </el-form>
  90. <div slot="footer" class="dialog-footer">
  91. <el-button @click="unitThree_Dialog = false">取 消</el-button>
  92. <el-button type="primary" @click="add_unitThree">确 定</el-button>
  93. </div>
  94. </el-dialog>
  95. <project-problem @dialogClose="showProblemDialog = false" :villType="'9'" :unitLevel="unitLevel" :currentRow="currentRow" :unitProblemInfo="unitProblemInfo" v-if="showProblemDialog"></project-problem>
  96. </el-container>
  97. </template>
  98. <script>
  99. import request from '../../../utils/gw_ajax_request.js'
  100. import projectProblem from "./projectProblem.vue";
  101. export default {
  102. props: ['currentRow'],
  103. data(){
  104. return{
  105. tableHeight: window.innerHeight - 210,
  106. unitTwoList: [],
  107. unitThreeList: [],
  108. unitTwo: {
  109. nm: ""
  110. },
  111. unitThree: {
  112. nm: "",
  113. pid: ""
  114. },
  115. dialogType: "添加",
  116. unitTwo_Dialog: false,
  117. unitThree_Dialog: false,
  118. showProblemDialog: false,
  119. unitProblemInfo: {},
  120. unitLevel: '', //一级管理单位 二级管理单位 三级管理单位
  121. currentUnitTwoRow: {},
  122. isClicked: true
  123. }
  124. },
  125. components: {
  126. projectProblem: projectProblem
  127. },
  128. computed: {
  129. persId() {
  130. return localStorage.getItem("userid")
  131. ? localStorage.getItem("userid")
  132. : "1098101939614724096";
  133. },
  134. },
  135. methods:{
  136. //获取二级单位列表信息
  137. getUnitTwoList() {
  138. let paramObj = {
  139. lev: "2",
  140. regId: this.currentRow.id
  141. };
  142. request.post(`/bis/insp/mampu/info/findByList`, paramObj).then(res => {
  143. if (res.success) {
  144. this.unitTwoList = res.data;
  145. if(this.unitTwoList.length){
  146. this.currentUnitTwoRow = this.unitTwoList[0]
  147. this.getUnitThreeList()
  148. }else{
  149. this.unitThreeList = []
  150. }
  151. }
  152. });
  153. },
  154. //获取三级单位列表信息
  155. getUnitThreeList() {
  156. let paramObj = {
  157. lev: "3",
  158. regId: this.currentRow.id,
  159. pid: this.currentUnitTwoRow.id
  160. };
  161. request.post(`/bis/insp/mampu/info/findByList`, paramObj).then(res => {
  162. if (res.success) {
  163. this.unitThreeList = res.data;
  164. }
  165. });
  166. },
  167. // 添加二级管理单位
  168. toAddUnitTwo() {
  169. if(!this.currentRow.oneUnitName){
  170. this.$message.warning('请先添加一级管理单位')
  171. return
  172. }
  173. this.dialogType = "添加";
  174. this.unitTwo = {
  175. nm: ""
  176. };
  177. this.unitTwo_Dialog = true;
  178. },
  179. toEditUnitTwo(row) {
  180. this.dialogType = "编辑";
  181. let rowData = {};
  182. Object.assign(rowData, row);
  183. this.unitTwo = rowData;
  184. this.unitTwo_Dialog = true;
  185. },
  186. add_unitTwo() {
  187. if(!this.unitTwo.nm){
  188. this.$message.warning('请填写二级单位名称')
  189. return
  190. }
  191. if(this.isClicked){
  192. this.isClicked = false
  193. if (this.dialogType == "添加") {
  194. this.unitTwo.lev = "2";
  195. this.unitTwo.regId = this.currentRow.id;
  196. this.unitTwo.pid = this.currentRow.oneUnitId;
  197. this.unitTwo.persId = this.persId;
  198. request
  199. .post(`/bis/insp/mampu/info/add`, this.unitTwo)
  200. .then(res => {
  201. if (res.success) {
  202. this.$message.success(this.dialogType + "成功");
  203. this.unitTwo_Dialog = false;
  204. this.getUnitTwoList();
  205. setTimeout(()=> {
  206. this.isClicked = true
  207. }, 1000);
  208. } else {
  209. this.$message.error(res.message);
  210. }
  211. })
  212. .catch(error => {
  213. this.$message.error(res.message);
  214. });
  215. } else {
  216. request
  217. .post(`/bis/insp/mampu/info/update`, this.unitTwo)
  218. .then(res => {
  219. if (res.success) {
  220. this.$message.success(this.dialogType + "成功");
  221. this.unitTwo_Dialog = false;
  222. this.getUnitTwoList();
  223. setTimeout(()=> {
  224. this.isClicked = true
  225. }, 1000);
  226. } else {
  227. this.$message.error(res.message);
  228. }
  229. })
  230. .catch(error => {
  231. this.$message.error(res.message);
  232. });
  233. }
  234. }
  235. },
  236. delete_unitTwo(row) {
  237. this.$confirm("确认删除当前二级单位吗?", "提示", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning"
  241. })
  242. .then(() => {
  243. request.post(`/bis/insp/mampu/info/delete/${row.id}`).then(res => {
  244. if (res.success) {
  245. this.$message.success("删除成功");
  246. this.getUnitTwoList();
  247. } else {
  248. this.$message.error(res.message);
  249. }
  250. });
  251. })
  252. .catch(() => {});
  253. },
  254. // 添加三级管理单位
  255. toAddUnitThree() {
  256. this.dialogType = "添加";
  257. this.unitThree = {
  258. nm: "",
  259. pid: this.currentUnitTwoRow.id
  260. };
  261. this.unitThree_Dialog = true;
  262. },
  263. toEditUnitThree(row) {
  264. this.dialogType = "编辑";
  265. let rowData = {};
  266. Object.assign(rowData, row);
  267. this.unitThree = rowData;
  268. this.unitThree_Dialog = true;
  269. },
  270. add_unitThree() {
  271. if(!this.unitThree.nm){
  272. this.$message.warning('请填写三级单位名称')
  273. return
  274. }
  275. if(this.isClicked){
  276. this.isClicked = false
  277. if (this.dialogType == "添加") {
  278. this.unitThree.lev = "3";
  279. this.unitThree.regId = this.currentRow.id;
  280. this.unitThree.pid = this.currentUnitTwoRow.id;
  281. this.unitThree.persId = this.persId;
  282. request
  283. .post(`/bis/insp/mampu/info/add`, this.unitThree)
  284. .then(res => {
  285. if (res.success) {
  286. this.$message.success(this.dialogType + "成功");
  287. this.unitThree_Dialog = false;
  288. this.getUnitThreeList();
  289. setTimeout(()=> {
  290. this.isClicked = true
  291. }, 1000);
  292. } else {
  293. this.$message.error(res.message);
  294. }
  295. })
  296. .catch(error => {
  297. this.$message.error(res.message);
  298. });
  299. } else {
  300. request
  301. .post(`/bis/insp/mampu/info/update`, this.unitThree)
  302. .then(res => {
  303. if (res.success) {
  304. this.$message.success(this.dialogType + "成功");
  305. this.unitThree_Dialog = false;
  306. this.getUnitThreeList();
  307. setTimeout(()=> {
  308. this.isClicked = true
  309. }, 1000);
  310. } else {
  311. this.$message.error(res.message);
  312. }
  313. })
  314. .catch(error => {
  315. this.$message.error(res.message);
  316. });
  317. }
  318. }
  319. },
  320. delete_unitThree(row) {
  321. this.$confirm("确认删除当前单位吗?", "提示", {
  322. confirmButtonText: "确定",
  323. cancelButtonText: "取消",
  324. type: "warning"
  325. })
  326. .then(() => {
  327. request.post(`/bis/insp/mampu/info/delete/${row.id}`).then(res => {
  328. if (res.success) {
  329. this.$message.success("删除成功");
  330. this.getUnitThreeList();
  331. } else {
  332. this.$message.error(res.message);
  333. }
  334. });
  335. })
  336. .catch(() => {});
  337. },
  338. showProblem(row,level){
  339. this.unitProblemInfo = row
  340. this.unitLevel = level
  341. this.showProblemDialog = true
  342. },
  343. //表格选中行操作
  344. handleCurrentChange_unitTwo(val){
  345. if(val){
  346. this.currentUnitTwoRow = val;
  347. this.getUnitThreeList()
  348. }
  349. },
  350. },
  351. watch:{
  352. currentRow(val){
  353. if (val) {
  354. this.getUnitTwoList();
  355. this.getUnitThreeList();
  356. }
  357. }
  358. },
  359. filters: {
  360. nature(val) {
  361. if (val != "0" && !val) {
  362. return "";
  363. }
  364. if (val == "1") {
  365. return "项目法人(建设单位)";
  366. } else if (val == "2") {
  367. return "勘察设计单位";
  368. } else if (val == "3") {
  369. return "监理单位";
  370. } else if (val == "4") {
  371. return "施工单位";
  372. } else if (val == "5") {
  373. return "金属结构及机电设备安装单位";
  374. } else if (val == "6") {
  375. return "安全监测单位";
  376. } else if (val == "7") {
  377. return "质量检测单位";
  378. } else {
  379. return "其它";
  380. }
  381. },
  382. government(val) {
  383. if (val != "0" && !val) {
  384. return "";
  385. }
  386. if (val == "1") {
  387. return "直管";
  388. } else if (val == "2") {
  389. return "代建";
  390. }
  391. }
  392. }
  393. }
  394. </script>
  395. <style scoped lang="scss">
  396. .main-item{
  397. width: 52%;
  398. &:first-child{
  399. width: 46%;
  400. margin-right: 0.5%;
  401. }
  402. }
  403. </style>