index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--左侧组织机构树-->
  5. <el-col :span="4" :xs="24">
  6. <div class="head-container">
  7. <el-input
  8. v-model="deptName"
  9. placeholder="请输入部门名称"
  10. clearable
  11. size="small"
  12. prefix-icon="el-icon-search"
  13. style="margin-bottom: 20px"
  14. />
  15. </div>
  16. <div class="head-container tree-scrollbar" style="height: 700px;overflow-y:auto;">
  17. <el-tree
  18. :data="deptOptions"
  19. :props="defaultProps"
  20. :expand-on-click-node="false"
  21. :filter-node-method="filterNode"
  22. ref="tree"
  23. node-key="id"
  24. :default-expanded-keys="[100]"
  25. @node-click="handleNodeClick"
  26. />
  27. </div>
  28. </el-col>
  29. <!--右侧部分-->
  30. <el-col :span="20" :xs="24">
  31. <!--条件查询区-->
  32. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  33. <el-form-item label="标题" prop="title">
  34. <el-input
  35. v-model="queryParams.title"
  36. placeholder="请输入标题"
  37. clearable
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <!--新增按钮区-->
  47. <el-row :gutter="10" class="mb8">
  48. <el-col :span="1.5">
  49. <el-button
  50. type="primary"
  51. plain
  52. icon="el-icon-plus"
  53. size="mini"
  54. @click="handleAdd"
  55. v-hasPermi="['hytz:cqcm:add']"
  56. >新增</el-button>
  57. </el-col>
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. <!--列表区-->
  61. <el-table v-loading="loading" :data="cqcmList" @selection-change="handleSelectionChange" >
  62. <el-table-column type="selection" width="55" align="center" />
  63. <el-table-column label="编号" align="center" prop="id" />
  64. <el-table-column label="标题" align="center" prop="title" />
  65. <!-- <el-table-column label="附件" align="center" prop="file" />-->
  66. <el-table-column label="创建人姓名" align="center" prop="createName" />
  67. <el-table-column label="创建时间" align="center" prop="createTime" />
  68. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  69. <template slot-scope="scope">
  70. <el-button
  71. size="mini"
  72. type="text"
  73. icon="el-icon-edit"
  74. @click="handleUpdate(scope.row)"
  75. v-hasPermi="['hytz:cqcm:edit']"
  76. >修改</el-button>
  77. <el-button
  78. size="mini"
  79. type="text"
  80. icon="el-icon-delete"
  81. @click="handleDelete(scope.row)"
  82. v-hasPermi="['hytz:cqcm:remove']"
  83. >删除</el-button>
  84. <el-button
  85. size="mini"
  86. type="text"
  87. icon="el-icon-view"
  88. @click="handleView(scope.row)"
  89. >详情</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <!--分页组件区-->
  94. <pagination
  95. v-show="total>0"
  96. :total="total"
  97. :page.sync="queryParams.pageNum"
  98. :limit.sync="queryParams.pageSize"
  99. @pagination="getList"
  100. />
  101. </el-col>
  102. </el-row>
  103. <!-- 添加或修改网格任务对话框 -->
  104. <el-dialog :title="title" :visible.sync="open" width="500px" >
  105. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  106. <el-row>
  107. <el-col :span="24">
  108. <el-form-item label="标题" prop="title" >
  109. <el-input v-model="form.title" placeholder="请输入标题" maxlength="15"/>
  110. </el-form-item>
  111. </el-col>
  112. </el-row>
  113. <el-row>
  114. <el-col :span="24">
  115. <el-form-item label="归属部门" prop="deptId">
  116. <treeselect
  117. :allowSelectingDisabledDescendants="true"
  118. v-model="form.deptId" :options="deptOptions" :show-count="true"
  119. placeholder="请选择归属部门"/>
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. <el-row>
  124. <el-col :span="24">
  125. <el-form-item label="图片附件">
  126. <image-upload v-model="form.imgFile" :limit="1"/>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. <el-row>
  131. <el-col :span="24">
  132. <el-form-item label="其他附件">
  133. <file-upload v-model="form.videoFile" :limit="1" :file-size="500"/>
  134. </el-form-item>
  135. </el-col>
  136. </el-row>
  137. </el-form>
  138. <div slot="footer" class="dialog-footer">
  139. <el-button type="primary" @click="submitForm" v-if="!findView">确 定</el-button>
  140. <el-button @click="cancel">取 消</el-button>
  141. </div>
  142. </el-dialog>
  143. </div>
  144. </template>
  145. <script>
  146. import {
  147. listVillageSentiment,
  148. updateVillageSentiment,
  149. addVillageSentiment,
  150. getVillageSentiment,
  151. delVillageSentiment
  152. } from '@/api/cqcm/cqcm'
  153. import { treeselect } from "@/api/system/dept";
  154. import Treeselect from "@riophae/vue-treeselect";
  155. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  156. import treeDept from "@/components/treeDept";
  157. export default {
  158. name: "Cqcm",
  159. components: { Treeselect,treeDept },
  160. data() {
  161. return {
  162. // 遮罩层
  163. loading: true,
  164. // 选中数组
  165. ids: [],
  166. // 非单个禁用
  167. single: true,
  168. // 非多个禁用
  169. multiple: true,
  170. // 显示搜索条件
  171. showSearch: true,
  172. // 总条数
  173. total: 0,
  174. // 网格任务信息表格数据
  175. cqcmList: [],
  176. // 弹出层标题
  177. title: "",
  178. // 是否显示弹出层
  179. open: false,
  180. // 部门树选项
  181. deptOptions: undefined,
  182. // 部门名称
  183. deptName: undefined,
  184. defaultProps: {
  185. children: 'children',
  186. label: 'label'
  187. },
  188. // 查询参数
  189. queryParams: {
  190. pageNum: 1,
  191. pageSize: 10,
  192. deptId: null,
  193. },
  194. // 表单参数
  195. form: {},
  196. // 是否禁用弹出层表单
  197. findView:false,
  198. // 表单校验
  199. rules: {
  200. title: [
  201. {required: true, message: "标题不能为空", trigger: "blur"},
  202. ],
  203. deptId: [
  204. {required: true, message: "归属部门不能为空", trigger: "blur"},
  205. ],
  206. },
  207. };
  208. },
  209. watch: {
  210. // 根据名称筛选部门树
  211. deptName(val) {
  212. this.$refs.tree.filter(val)
  213. }
  214. },
  215. created() {
  216. this.getList();
  217. this.getTreeselect();
  218. },
  219. methods: {
  220. /** 查询网格任务列表 */
  221. getList() {
  222. this.loading = true;
  223. listVillageSentiment(this.queryParams).then(response => {
  224. this.cqcmList = response.rows;
  225. this.total = response.total;
  226. this.loading = false;
  227. });
  228. },
  229. /** 查询部门下拉树结构 */
  230. getTreeselect() {
  231. treeselect().then(response => {
  232. this.deptOptions = response.data;
  233. });
  234. },
  235. // 取消按钮
  236. cancel() {
  237. this.open = false;
  238. this.reset();
  239. },
  240. // 表单重置
  241. reset() {
  242. this.form = {
  243. id: null,
  244. deptIds: null,
  245. deptId: null,
  246. title: null,
  247. createBy: null,
  248. createName: null,
  249. createTime: null,
  250. updateBy: null,
  251. updateName: null,
  252. updateTime: null,
  253. imgFile: null,
  254. videoFile: null
  255. };
  256. this.resetForm("form");
  257. },
  258. fileNameList(fileNames){
  259. this.form.fileObjectName = fileNames;
  260. },
  261. /** 搜索按钮操作 */
  262. handleQuery() {
  263. this.queryParams.pageNum = 1;
  264. this.getList();
  265. },
  266. /** 重置按钮操作 */
  267. resetQuery() {
  268. this.resetForm("queryForm");
  269. this.handleQuery();
  270. },
  271. // 多选框选中数据
  272. handleSelectionChange(selection) {
  273. this.ids = selection.map(item => item.id)
  274. this.single = selection.length!==1
  275. this.multiple = !selection.length
  276. },
  277. /** 新增按钮操作 */
  278. handleAdd() {
  279. this.reset();
  280. this.form.deptIds = [];
  281. this.open = true;
  282. this.hasVmodel = true;
  283. this.findView=false;
  284. this.title = "添加村情村貌信息";
  285. },
  286. /** 修改按钮操作 */
  287. handleUpdate(row) {
  288. this.reset();
  289. this.findView=false;
  290. this.getTreeselect();
  291. const id = row.id || this.ids
  292. getVillageSentiment(id).then(response => {
  293. this.form = response.data;
  294. this.form.deptId = response.data.deptId;
  295. this.open = true;
  296. this.title = "修改村情村貌信息";
  297. });
  298. },
  299. /** 查看详情按钮操作 */
  300. handleView(row) {
  301. this.findView = true;
  302. const id = row.id || this.ids
  303. getVillageSentiment(id).then(response => {
  304. this.form = response.data;
  305. this.form.deptId = response.data.deptId;
  306. this.open = true;
  307. this.hasVmodel = false;
  308. this.title = "村情村貌信息详情";
  309. });
  310. },
  311. /** 提交按钮 */
  312. submitForm() {
  313. this.$refs["form"].validate(valid => {
  314. if (valid) {
  315. if (this.form.id != null) {
  316. updateVillageSentiment(this.form).then(response => {
  317. this.$modal.msgSuccess("修改成功");
  318. this.open = false;
  319. this.getList();
  320. });
  321. } else {
  322. addVillageSentiment(this.form).then(response => {
  323. this.$modal.msgSuccess("新增成功");
  324. this.open = false;
  325. this.getList();
  326. });
  327. }
  328. }
  329. });
  330. },
  331. /** 删除按钮操作 */
  332. handleDelete(row) {
  333. const ids = row.id || this.ids;
  334. this.$modal.confirm('确认要删除此数据?').then(function() {
  335. return delVillageSentiment(ids);
  336. }).then(() => {
  337. this.getList();
  338. this.$modal.msgSuccess("删除成功");
  339. }).catch(() => {
  340. });
  341. },
  342. // 筛选节点
  343. filterNode(value, data) {
  344. if (!value) return true
  345. return data.label.indexOf(value) !== -1
  346. },
  347. // 节点单击事件
  348. handleNodeClick(data) {
  349. this.queryParams.deptId = data.id
  350. this.handleQuery()
  351. },
  352. getDeptName(param){
  353. this.form.deptName=param;
  354. },
  355. }
  356. };
  357. </script>