index.vue 12 KB

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