index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" @submit.native.prevent>
  4. <el-form-item label="名称" prop="regName">
  5. <el-input
  6. v-model="queryParams.regName"
  7. placeholder="请输入名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item prop="deptId">
  13. <template slot="label">
  14. <span @click="changeQueryType" v-if="queryParams.deptName === 0">本级及下级</span>
  15. <span @click="changeQueryType" v-if="queryParams.deptName === 1">只查询本级</span>
  16. </template>
  17. <treeselect v-model="queryParams.deptId" :options="deptOptions" multiple:false :show-count="true"
  18. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'" style="width: 240px"/>
  19. <el-input v-model="queryParams.deptName" v-if="false"/>
  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. plain
  31. icon="el-icon-plus"
  32. size="mini"
  33. @click="handleAdd"
  34. v-hasPermi="['system:regulations:add']"
  35. >新增
  36. </el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['system:regulations:edit']"
  47. >修改
  48. </el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="danger"
  53. plain
  54. icon="el-icon-delete"
  55. size="mini"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. v-hasPermi="['system:regulations:remove']"
  59. >删除
  60. </el-button>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button
  64. type="warning"
  65. plain
  66. icon="el-icon-download"
  67. size="mini"
  68. @click="handleExport"
  69. v-hasPermi="['system:regulations:export']"
  70. >导出
  71. </el-button>
  72. </el-col>
  73. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  74. </el-row>
  75. <el-table v-loading="loading" :data="regulationsList" @selection-change="handleSelectionChange">
  76. <el-table-column type="selection" width="55" align="center"/>
  77. <!-- <el-table-column label="主键id" align="center" prop="id" />
  78. <el-table-column label="数据状态(1-可用 2-不可用 )" align="center" prop="dataStatus" />-->
  79. <!-- <el-table-column label="数据所属部门(政或党的id)" align="center" prop="dataDeptId" />-->
  80. <el-table-column label="名称" align="center" prop="regName"/>
  81. <el-table-column label="法规简介" align="center" prop="regIntroduction"/>
  82. <el-table-column label="发文机关" align="center" prop="regOffice"/>
  83. <el-table-column label="发文号" align="center" prop="regNumber"/>
  84. <el-table-column label="发文时间" align="center" prop="regTime" width="180">
  85. <template slot-scope="scope">
  86. <span>{{ parseTime(scope.row.regTime, '{y}-{m}-{d}') }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="发布状态" align="center" prop="varieties">
  90. <template slot-scope="scope">
  91. <dict-tag :options="dict.type.centerdata_release_status" :value="scope.row.releaseStatus"/>
  92. </template>
  93. </el-table-column>
  94. <!-- <el-table-column label="部门id" align="center" prop="deptId" />-->
  95. <el-table-column label="所属部门" align="center" prop="deptName"/>
  96. <el-table-column label="创建人" align="center" prop="createName"/>
  97. <el-table-column label="创建时间" align="center" prop="createTime"/>
  98. <el-table-column label="修改人" align="center" prop="updateName"/>
  99. <el-table-column label="修改时间" align="center" prop="updateTime"/>
  100. <!-- <el-table-column label="附件" align="center" prop="attachId" />-->
  101. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  102. <template slot-scope="scope">
  103. <el-button
  104. size="mini"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['system:regulations:edit']"
  109. >修改
  110. </el-button>
  111. <el-button
  112. size="mini"
  113. type="text"
  114. icon="el-icon-delete"
  115. @click="handleDelete(scope.row)"
  116. v-hasPermi="['system:regulations:remove']"
  117. >删除
  118. </el-button>
  119. <el-button v-if="scope.row.releaseStatus == 'centerdata_release_status_yes'" size="mini" type="text" icon="el-icon-refresh-left" @click="handlePublish(scope.row)" v-hasPermi="['system:reserve:edit']">
  120. 撤销
  121. </el-button>
  122. <el-button v-else-if="scope.row.releaseStatus == 'centerdata_release_status_no'" size="mini" type="text" icon="el-icon-upload" @click="handlePublish(scope.row)" v-hasPermi="['system:reserve:edit']">
  123. 发布
  124. </el-button>
  125. <el-button
  126. size="mini"
  127. type="text"
  128. icon="el-icon-edit"
  129. @click="See(scope.row)"
  130. v-hasPermi="['forest:regulations:edit']"
  131. >查看
  132. </el-button>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <pagination
  137. v-show="total>0"
  138. :total="total"
  139. :page.sync="queryParams.pageNum"
  140. :limit.sync="queryParams.pageSize"
  141. @pagination="getList"
  142. />
  143. <!-- 添加或修改政策法规对话框 -->
  144. <el-dialog :title="title" :visible.sync="open" width="800px" class="form-style">
  145. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  146. <el-row>
  147. <el-col :span="12">
  148. <el-form-item label="名称" prop="regName">
  149. <el-input v-model="form.regName" placeholder="请输入名称" maxlength="50"/>
  150. </el-form-item>
  151. <el-form-item label="所属部门" prop="deptId">
  152. <treeselect v-model="form.deptId" :options="deptOptions" multiple:false :show-count="true"
  153. placeholder="请选择所属部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'"/>
  154. </el-form-item>
  155. <el-form-item label="发文时间" prop="regTime">
  156. <el-date-picker clearable
  157. v-model="form.regTime"
  158. type="date"
  159. value-format="yyyy-MM-dd"
  160. placeholder="请选择发文时间">
  161. </el-date-picker>
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="12">
  165. <el-form-item label="发文机关" prop="regOffice">
  166. <el-input v-model="form.regOffice" placeholder="请输入发文机关" maxlength="50"/>
  167. </el-form-item>
  168. <el-form-item label="发文号" prop="regNumber">
  169. <el-input v-model="form.regNumber" placeholder="请输入发文号" maxlength="50"/>
  170. </el-form-item>
  171. </el-col>
  172. </el-row>
  173. <el-row>
  174. <el-col :span="24">
  175. <!-- <el-form-item label="法规简介" prop="regIntroduction">
  176. <editor v-model="form.regIntroduction" :min-height="192" maxlength="512"/>
  177. </el-form-item>-->
  178. <el-form-item label="法规简介" prop="regIntroduction" label-width="120px">
  179. <el-input v-model="form.regIntroduction" type="textarea" placeholder="请输入内容" maxlength="200"/>
  180. </el-form-item>
  181. </el-col>
  182. </el-row>
  183. <el-row>
  184. <el-col :span="24">
  185. <el-form-item label="附件" prop="attachId">
  186. <fileUpload :value="[form.fileUrl,form.fileName]" v-model="form.fileUrl" :setFileName="setFileName"
  187. :removeFileName="removeFileName" :limit="1"></fileUpload>
  188. </el-form-item>
  189. </el-col>
  190. </el-row>
  191. </el-form>
  192. <div slot="footer" class="dialog-footer">
  193. <el-button type="primary" @click="submitForm">确 定</el-button>
  194. <el-button @click="cancel">取 消</el-button>
  195. </div>
  196. </el-dialog>
  197. <!--详情 -->
  198. <el-dialog :title="title" :visible.sync="seeopen" width="800px" class="form-style" append-to-body>
  199. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  200. <el-row>
  201. <el-col :span="12">
  202. <el-form-item label="所属部门" prop="dataDeptId" label-width="120px">
  203. <deptselector :setValue=setDataDeptId :dataDeptId="form.dataDeptId"></deptselector>
  204. </el-form-item>
  205. <el-form-item label="名称" prop="regName">
  206. <el-input v-model="form.regName" placeholder="请输入名称" :disabled="true" maxlength="50"/>
  207. </el-form-item>
  208. <!-- <el-form-item label="法规简介" prop="regIntroduction">
  209. <el-input v-model="form.regIntroduction" placeholder="请输入法规简介" :disabled="true" maxlength="512"/>
  210. </el-form-item>-->
  211. <el-form-item label="法规简介" prop="regIntroduction" label-width="120px">
  212. <el-input v-model="form.regIntroduction" type="textarea" placeholder="请输入内容" maxlength="200"/>
  213. </el-form-item>
  214. <el-form-item label="发文时间" prop="regTime">
  215. <el-date-picker clearable :disabled="true"
  216. v-model="form.regTime"
  217. type="date"
  218. value-format="yyyy-MM-dd"
  219. placeholder="请选择发文时间">
  220. </el-date-picker>
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="12">
  224. <el-form-item label="发文机关" prop="regOffice">
  225. <el-input v-model="form.regOffice" placeholder="请输入发文机关" :disabled="true" maxlength="50"/>
  226. </el-form-item>
  227. <el-form-item label="发文号" prop="regNumber">
  228. <el-input v-model="form.regNumber" placeholder="请输入发文号" :disabled="true" maxlength="50"/>
  229. </el-form-item>
  230. <el-form-item label="所属部门" prop="deptId">
  231. <treeselect :options="deptOptions" v-model="form.deptId" :show-count="true" placeholder="请选择所属部门"
  232. @select="hx" :disabled="true" :noResultsText="'空'" :noOptionsText="'空'"/>
  233. </el-form-item>
  234. <el-form-item label="附件" prop="attachId">
  235. <fileUpload @input="getUrl" v-model="form.fileUrl"></fileUpload>
  236. </el-form-item>
  237. </el-col>
  238. </el-row>
  239. </el-form>
  240. <div slot="footer" class="dialog-footer">
  241. <el-button @click="cancelSel">取 消</el-button>
  242. </div>
  243. </el-dialog>
  244. </div>
  245. </template>
  246. <script>
  247. import {
  248. addRegulations,
  249. delRegulations,
  250. getRegulations,
  251. listRegulations,
  252. updateRegulations,
  253. updateRelease
  254. } from "@/api/data/regulations/regulations";
  255. import {treeselect} from "@/api/system/dept";
  256. import Treeselect from "@riophae/vue-treeselect";
  257. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  258. import deptselector from '@/views/components/deptselector.vue'
  259. import fileUpload from '@/views/components/FileUpload/index.vue'
  260. export default {
  261. components: {
  262. Treeselect,
  263. deptselector,
  264. fileUpload
  265. },
  266. name: "Regulations",
  267. dicts: ["centerdata_release_status"],
  268. data() {
  269. return {
  270. // 遮罩层
  271. loading: true,
  272. // 选中数组
  273. ids: [],
  274. // 非单个禁用
  275. single: true,
  276. // 非多个禁用
  277. multiple: true,
  278. // 显示搜索条件
  279. showSearch: true,
  280. // 总条数
  281. total: 0,
  282. // 政策法规表格数据
  283. regulationsList: [],
  284. fileNames: [],
  285. // 弹出层标题
  286. title: "",
  287. // 是否显示弹出层
  288. open: false,
  289. seeopen: false,
  290. // 部门树选项
  291. deptOptions: [],
  292. // 查询参数
  293. queryParams: {
  294. releaseStatus: null,
  295. pageNum: 1,
  296. pageSize: 10,
  297. dataStatus: null,
  298. dataDeptId: null,
  299. regName: null,
  300. regIntroduction: null,
  301. regOffice: null,
  302. regNumber: null,
  303. regTime: null,
  304. deptId: null,
  305. deptName: 0,
  306. attachId: null
  307. },
  308. // 表单参数
  309. form: {
  310. dataDeptId: 0,
  311. releaseStatus: 'centerdata_release_status_no',
  312. fileUrl: '',
  313. fileName: '',
  314. fileUrlList: [],
  315. fileNameList: []
  316. },
  317. // 表单校验
  318. rules: {
  319. deptId: [
  320. {required: true, message: "所属部门不能为空", trigger: "change"}
  321. ],
  322. regName: [
  323. {required: true, message: "名称不能为空", trigger: "blur"}
  324. ],
  325. regOffice: [
  326. {required: true, message: "发文机关不能为空", trigger: "blur"}
  327. ],
  328. regNumber: [
  329. {required: true, message: "发文号不能为空", trigger: "blur"}
  330. ]
  331. }
  332. };
  333. },
  334. created() {
  335. this.getList();
  336. this.getTreeselect();
  337. },
  338. methods: {
  339. getUrl(url) {
  340. alert('0');
  341. },
  342. setFileName(fileName) {
  343. let that = this
  344. that.fileNames.push(fileName)
  345. },
  346. removeFileName(index) {
  347. let that = this
  348. that.fileNames.splice(index, 1);
  349. let fileurls = that.form.fileUrl.split(",")
  350. fileurls.splice(index, 1)
  351. that.form.fileUrl = fileurls.toString()
  352. },
  353. // 取消按钮
  354. cancelSel() {
  355. this.seeopen = false;
  356. this.reset();
  357. },
  358. See(row) {
  359. this.reset();
  360. const id = row.id || this.ids
  361. getRegulations(id).then(response => {
  362. this.form = response.data;
  363. this.seeopen = true;
  364. this.title = "查看";
  365. });
  366. },
  367. setDataDeptId(e) {
  368. this.form.dataDeptId = e.deptId
  369. this.form.dataDeptName = e.deptName
  370. },
  371. hx(node) {
  372. this.form.deptId = node.id
  373. this.form.deptName = node.label
  374. },
  375. /** 查询部门下拉树结构 */
  376. getTreeselect() {
  377. treeselect().then(response => {
  378. this.deptOptions = response.data;
  379. });
  380. },
  381. /** 查询政策法规列表 */
  382. getList() {
  383. this.loading = true;
  384. listRegulations(this.queryParams).then(response => {
  385. this.regulationsList = response.rows;
  386. this.total = response.total;
  387. this.loading = false;
  388. });
  389. },
  390. // 取消按钮
  391. cancel() {
  392. this.open = false;
  393. this.reset();
  394. },
  395. // 表单重置
  396. reset() {
  397. this.form = {
  398. id: null,
  399. createBy: null,
  400. createTime: null,
  401. updateBy: null,
  402. updateTime: null,
  403. dataStatus: "0",
  404. dataDeptId: '',
  405. regName: null,
  406. regIntroduction: null,
  407. regOffice: null,
  408. regNumber: null,
  409. regTime: null,
  410. deptId: null,
  411. deptName: 0,
  412. attachId: null,
  413. };
  414. this.fileNames = []
  415. this.resetForm("form");
  416. },
  417. /** 搜索按钮操作 */
  418. handleQuery() {
  419. this.queryParams.pageNum = 1;
  420. this.getList();
  421. },
  422. /** 重置按钮操作 */
  423. resetQuery() {
  424. this.queryParams.deptName = 0;
  425. this.resetForm("queryForm");
  426. this.handleQuery();
  427. },
  428. // 多选框选中数据
  429. handleSelectionChange(selection) {
  430. this.ids = selection.map(item => item.id)
  431. this.single = selection.length !== 1
  432. this.multiple = !selection.length
  433. },
  434. /** 新增按钮操作 */
  435. handleAdd() {
  436. this.reset();
  437. this.open = true;
  438. this.title = "添加政策法规";
  439. },
  440. /** 修改按钮操作 */
  441. handleUpdate(row) {
  442. this.reset();
  443. const id = row.id || this.ids
  444. getRegulations(id).then(response => {
  445. const list = response.data.fileUrl.split(',');
  446. var item1
  447. if (response.data.fileUrl != "") {
  448. for (var a = 0; a < list.length; a++) {
  449. let listurl = list[a].split('+')
  450. this.fileNames.push(listurl[1])
  451. }
  452. }
  453. this.form = response.data;
  454. this.open = true;
  455. this.title = "修改政策法规";
  456. });
  457. },
  458. /** 提交按钮 */
  459. submitForm() {
  460. this.$refs["form"].validate(valid => {
  461. if (valid) {
  462. this.form.fileName = this.fileNames.toString()
  463. this.form.fileNameList = this.fileNames;
  464. this.form.fileUrlList = Array.from(document.querySelectorAll('.el-upload-list__item')).map(item => item.querySelector('a').getAttribute('href'));
  465. if (this.form.id != null) {
  466. updateRegulations(this.form).then(response => {
  467. this.$modal.msgSuccess("修改成功");
  468. this.open = false;
  469. this.getList();
  470. });
  471. } else {
  472. this.form.releaseStatus = "centerdata_release_status_no";
  473. addRegulations(this.form).then(response => {
  474. this.$modal.msgSuccess("新增成功");
  475. this.open = false;
  476. this.getList();
  477. });
  478. }
  479. }
  480. });
  481. },
  482. /** 删除按钮操作 */
  483. handleDelete(row) {
  484. const ids = row.id || this.ids;
  485. this.$modal.confirm('是否删除选中的数据?').then(function () {
  486. return delRegulations(ids);
  487. }).then(() => {
  488. this.getList();
  489. this.$modal.msgSuccess("删除成功");
  490. }).catch(() => {
  491. });
  492. },
  493. handlePublish(row) {
  494. let ids = row.id || this.ids;
  495. let status = "发布", releaseStatus = "centerdata_release_status_yes";
  496. if (!ids.includes(",")) {
  497. ids = [ids];
  498. if (row.releaseStatus.includes("centerdata_release_status_yes")) {
  499. status = "撤销";
  500. releaseStatus = "centerdata_release_status_no";
  501. }
  502. this.$modal.confirm('是否' + status + '选中的数据?').then(function () {
  503. return updateRelease(ids, releaseStatus);
  504. }).then(() => {
  505. this.getList();
  506. this.$modal.msgSuccess(status + "成功");
  507. }).catch((e) => {
  508. console.log(e)
  509. });
  510. }
  511. },
  512. /** 导出按钮操作 */
  513. handleExport() {
  514. this.download('sooka-sponest-center-data/regulations/export', {
  515. ...this.queryParams
  516. }, `政策法规_${new Date().getTime()}.xlsx`)
  517. },
  518. // 点击按钮修改是否只查询本级部门用户
  519. changeQueryType() {
  520. this.queryParams.deptName = this.queryParams.deptName === 0 ? 1 : 0;
  521. }
  522. }
  523. };
  524. </script>