index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="房产类型" prop="type">
  5. <el-select v-model="queryParams.type" placeholder="请选择类型" clearable @keyup.enter.native="handleQuery">
  6. <el-option
  7. v-for="item in options"
  8. :key="item.label"
  9. :label="item.label"
  10. :value="item.value">
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="所属单位" prop="appOrg">
  15. <el-cascader :options="treeList" placeholder="请选择所属单位" v-model="queryParams.appOrg" :props="props" style="width: 400px">
  16. <template slot-scope="{ node, data }">
  17. <span>{{ data.appName }}</span>
  18. </template>
  19. </el-cascader>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  23. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-row :gutter="10" class="mb8">
  27. <el-col :span="1.5">
  28. <el-button
  29. type="primary"
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. v-hasPermi="['zcustom:platHousingLand:add']"
  34. >新增</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="danger"
  39. icon="el-icon-delete"
  40. size="mini"
  41. :disabled="multiple"
  42. @click="handleDelete"
  43. v-hasPermi="['zcustom:platHousingLand:remove']"
  44. >删除</el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button
  48. type="warning"
  49. icon="el-icon-upload"
  50. size="mini"
  51. @click="handleUpload"
  52. >导入</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <input v-show="false" type="file" ref="fileInput" @change="handleFileChange" />
  56. </el-col>
  57. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. <el-table v-loading="loading" :data="platHousingLandList" @selection-change="handleSelectionChange">
  60. <el-table-column type="selection" width="55" align="center" />
  61. <el-table-column label="序号" width="50">
  62. <template slot-scope="scope">
  63. {{(scope.$index + 1) + ((queryParams.pageNum - 1) * queryParams.pageSize)}}
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="房产数量" align="center" prop="houseNum" />
  67. 房产面积
  68. 土地数量
  69. 土地面积
  70. <el-table-column label="房产面积" align="center" prop="houseAcreage" />
  71. <el-table-column label="土地数量" align="center" prop="landNum" />
  72. <el-table-column label="土地面积" align="center" prop="landAcreage" />
  73. <el-table-column label="房产类型" align="center" prop="type">
  74. <template slot-scope="scope">
  75. {{options[scope.row.type].label}}
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="所属单位" align="center" prop="appOrg">
  79. <template slot-scope="scope">
  80. {{findLabelByValue(treeList, scope.row.appOrg ? scope.row.appOrg : null)}}
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-edit"
  89. @click="handleUpdate(scope.row)"
  90. v-hasPermi="['zcustom:platHousingLand:edit']"
  91. >修改</el-button>
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-delete"
  96. @click="handleDelete(scope.row)"
  97. v-hasPermi="['zcustom:platHousingLand:remove']"
  98. >删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination
  103. v-show="total>0"
  104. :total="total"
  105. :page.sync="queryParams.pageNum"
  106. :limit.sync="queryParams.pageSize"
  107. @pagination="getList"
  108. />
  109. <!-- 添加或修改房产土地对话框 -->
  110. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="800px" append-to-body>
  111. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  112. <el-form-item label="房产数量" prop="houseNum">
  113. <el-input v-model="form.houseNum" placeholder="请输入房产名称" />
  114. </el-form-item>
  115. <el-form-item label="房产面积" prop="houseAcreage">
  116. <el-input v-model="form.houseAcreage" placeholder="请输入房产面积" />
  117. </el-form-item>
  118. <el-form-item label="土地数量" prop="houseNum">
  119. <el-input v-model="form.landNum" placeholder="请输入土地数量" />
  120. </el-form-item>
  121. <el-form-item label="土地面积" prop="houseAcreage">
  122. <el-input v-model="form.landAcreage" placeholder="请输入土地面积" />
  123. </el-form-item>
  124. <el-form-item label="房产类型" prop="type">
  125. <el-select v-model="form.type" placeholder="请选择类型">
  126. <el-option
  127. v-for="item in options"
  128. :key="item.label"
  129. :label="item.label"
  130. :value="item.value">
  131. </el-option>
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item label="所属单位" prop="appOrg">
  135. <el-cascader :options="treeList" placeholder="请选择所属单位" v-model="form.appOrg" :props="props" style="width: 400px">
  136. <template slot-scope="{ node, data }">
  137. <span>{{ data.appName }}</span>
  138. </template>
  139. </el-cascader>
  140. </el-form-item>
  141. </el-form>
  142. <div slot="footer" class="dialog-footer">
  143. <el-button type="primary" @click="submitForm">确 定</el-button>
  144. <el-button @click="cancel">取 消</el-button>
  145. </div>
  146. </el-dialog>
  147. </div>
  148. </template>
  149. <script>
  150. import {
  151. listPlatHousingLand,
  152. getPlatHousingLand,
  153. delPlatHousingLand,
  154. addPlatHousingLand,
  155. updatePlatHousingLand,
  156. uploadExcel
  157. } from '@/api/zcustom/land'
  158. import { parseTime } from '../../../utils/ruoyi'
  159. import { getListTree } from '@/api/zcustom/platAppOrg'
  160. export default {
  161. name: "PlatHousingLand",
  162. data() {
  163. return {
  164. treeList:[],
  165. props:{
  166. value: 'appOrg',
  167. label: 'appName',
  168. checkStrictly: true,
  169. emitPath: false
  170. },
  171. options:[
  172. {
  173. value: 0,
  174. label: "供电所"
  175. },
  176. {
  177. value: 1,
  178. label: "物资仓储"
  179. },
  180. {
  181. value: 2,
  182. label: "办公"
  183. },
  184. {
  185. value: 3,
  186. label: "周转"
  187. }
  188. ],
  189. // 根路径
  190. baseURL: process.env.VUE_APP_BASE_API,
  191. // 遮罩层
  192. loading: true,
  193. // 选中数组
  194. ids: [],
  195. // 非单个禁用
  196. single: true,
  197. // 非多个禁用
  198. multiple: true,
  199. // 显示搜索条件
  200. showSearch: true,
  201. // 总条数
  202. total: 0,
  203. // 房产土地表格数据
  204. platHousingLandList: [],
  205. // 弹出层标题
  206. title: "",
  207. // 是否显示弹出层
  208. open: false,
  209. // 查询参数
  210. queryParams: {
  211. pageNum: 1,
  212. pageSize: 10,
  213. housing: null,
  214. acreage: null,
  215. type: null,
  216. constructionTime: null,
  217. ownershipFlag: null,
  218. investmentPlanFlag: null
  219. },
  220. // 表单参数
  221. form: {},
  222. // 表单校验
  223. rules: {
  224. houseNum: [
  225. { required: true, message: "房产数量不能为空", trigger: "blur" }
  226. ],
  227. houseAcreage: [
  228. { required: true, message: "房产面积不能为空", trigger: "blur" }
  229. ],
  230. landNum: [
  231. { required: true, message: "土地数量不能为空", trigger: "blur" }
  232. ],
  233. landAcreage: [
  234. { required: true, message: "土地面积不能为空", trigger: "blur" }
  235. ],
  236. type: [
  237. { required: true, message: "房产类型不能为空", trigger: "change" }
  238. ],
  239. ownershipFlag: [
  240. { required: true, message: "所有权状态不能为空", trigger: "change" }
  241. ],
  242. appOrg: [
  243. { required: true, message: "所属单位id不能为空", trigger: "blur" }
  244. ]
  245. }
  246. };
  247. },
  248. created() {
  249. this.getList();
  250. this.getListTree();
  251. },
  252. methods: {
  253. parseTime,
  254. /** 查询房产土地列表 */
  255. getList() {
  256. this.loading = true;
  257. listPlatHousingLand(this.queryParams).then(response => {
  258. this.platHousingLandList = response.data.records;
  259. this.total = response.data.total;
  260. this.loading = false;
  261. });
  262. },
  263. // 取消按钮
  264. cancel() {
  265. this.open = false;
  266. this.reset();
  267. },
  268. // 表单重置
  269. reset() {
  270. this.form = {
  271. id: null,
  272. delFlag: null,
  273. housing: null,
  274. acreage: null,
  275. type: null,
  276. constructionTime: null,
  277. ownershipFlag: null,
  278. investmentPlanFlag: null
  279. };
  280. this.resetForm("form");
  281. },
  282. getListTree(){
  283. getListTree().then(res => {
  284. this.treeList.push(res.data)
  285. })
  286. },
  287. /** 搜索按钮操作 */
  288. handleQuery() {
  289. this.queryParams.pageNum = 1;
  290. this.getList();
  291. },
  292. /** 重置按钮操作 */
  293. resetQuery() {
  294. this.resetForm("queryForm");
  295. this.handleQuery();
  296. },
  297. // 多选框选中数据
  298. handleSelectionChange(selection) {
  299. this.ids = selection.map(item => item.id)
  300. this.single = selection.length!==1
  301. this.multiple = !selection.length
  302. },
  303. /** 新增按钮操作 */
  304. handleAdd() {
  305. this.reset();
  306. this.open = true;
  307. this.title = "添加房产土地";
  308. },
  309. /** 修改按钮操作 */
  310. handleUpdate(row) {
  311. this.reset();
  312. const id = row.id || this.ids
  313. getPlatHousingLand(id).then(response => {
  314. this.form = response.data;
  315. this.open = true;
  316. this.title = "修改房产土地";
  317. });
  318. },
  319. /** 提交按钮 */
  320. submitForm() {
  321. this.$refs["form"].validate(valid => {
  322. if (valid) {
  323. if (this.form.id != null) {
  324. updatePlatHousingLand(this.form).then(response => {
  325. this.$modal.msgSuccess("修改成功");
  326. this.open = false;
  327. this.getList();
  328. });
  329. } else {
  330. addPlatHousingLand(this.form).then(response => {
  331. this.$modal.msgSuccess("新增成功");
  332. this.open = false;
  333. this.getList();
  334. });
  335. }
  336. }
  337. });
  338. },
  339. /** 删除按钮操作 */
  340. handleDelete(row) {
  341. const ids = row.id || this.ids;
  342. this.$modal.confirm('是否确认删除?').then(function() {
  343. return delPlatHousingLand(ids);
  344. }).then(() => {
  345. this.getList();
  346. this.$modal.msgSuccess("删除成功");
  347. }).catch(() => {});
  348. },
  349. /** 导入按钮操作 */
  350. handleUpload() {
  351. this.$refs.fileInput.click()
  352. },
  353. handleFileChange(event) {
  354. const selectedFile = event.target.files[0];
  355. const formData = new FormData();
  356. formData.append('file', selectedFile);
  357. uploadExcel(formData).then(res =>{
  358. if (res.code === 200){
  359. this.$modal.msgSuccess("导入成功");
  360. }
  361. });
  362. },
  363. findLabelByValue(list, appOrg) {
  364. for (const item of list) {
  365. if (item.appOrg === appOrg) {
  366. return item.appName;
  367. }
  368. if (item.children) {
  369. const result = this.findLabelByValue(item.children, appOrg);
  370. if (result !== '无') return result;
  371. }
  372. }
  373. return "无";
  374. }
  375. }
  376. };
  377. </script>