index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="68px"
  10. >
  11. <el-form-item label="行政区">
  12. <!-- <el-col :span="4"> -->
  13. <treeselect
  14. v-model="queryParams.xzqdm"
  15. :options="deptOptions"
  16. :normalizer="normalizer"
  17. placeholder="选择行政区"
  18. noOptionsText="暂无数据"
  19. noChildrenText="没有子选项"
  20. :value="selectedValues"
  21. @select="treeselecthange"
  22. />
  23. <!-- </el-col> -->
  24. </el-form-item>
  25. <el-form-item label="活动时间">
  26. <el-col :span="11">
  27. <el-date-picker
  28. type="date"
  29. placeholder="选择日期"
  30. v-model="queryParams.filetime"
  31. style="width: 100%"
  32. value-format="yyyy-MM-dd"
  33. ></el-date-picker>
  34. </el-col>
  35. <el-col class="line" :span="2">-</el-col>
  36. <el-col :span="11">
  37. <el-date-picker
  38. type="date"
  39. placeholder="选择日期"
  40. v-model="queryParams.readtime"
  41. style="width: 100%"
  42. value-format="yyyy-MM-dd"
  43. ></el-date-picker>
  44. </el-col>
  45. </el-form-item>
  46. <el-form-item label="文件名称">
  47. <el-input
  48. v-model="queryParams.name"
  49. placeholder="请输入文件名称"
  50. clearable
  51. @keyup.enter.native="handleQuery"
  52. />
  53. </el-form-item>
  54. <el-form-item>
  55. <el-button
  56. type="primary"
  57. icon="el-icon-search"
  58. size="mini"
  59. @click="handleQuery"
  60. v-hasPermi="['supervise:pcsj:list']"
  61. >搜索</el-button
  62. >
  63. <el-button
  64. icon="el-icon-refresh"
  65. size="mini"
  66. @click="resetQuery"
  67. v-hasPermi="['supervise:pcsj:list']"
  68. >重置</el-button
  69. >
  70. </el-form-item>
  71. </el-form>
  72. <el-row :gutter="10" class="mb8">
  73. <el-col :span="1.5">
  74. <el-button
  75. type="primary"
  76. plain
  77. icon="el-icon-upload"
  78. @click="fileUploadHandle"
  79. size="mini"
  80. v-hasPermi="['supervise:pcsj:upload']"
  81. >上传</el-button
  82. >
  83. </el-col>
  84. <!-- <el-col :span="1.5">
  85. <el-button
  86. type="primary"
  87. plain
  88. icon="el-icon-plus"
  89. size="mini"
  90. @click="handleAdd"
  91. v-hasPermi="['supervise:pcsj:add']"
  92. >新增</el-button
  93. >
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-button
  97. type="success"
  98. plain
  99. icon="el-icon-edit"
  100. size="mini"
  101. :disabled="single"
  102. @click="handleUpdate"
  103. v-hasPermi="['supervise:pcsj:edit']"
  104. >修改</el-button
  105. >
  106. </el-col>
  107. <el-col :span="1.5">
  108. <el-button
  109. type="danger"
  110. plain
  111. icon="el-icon-delete"
  112. size="mini"
  113. :disabled="multiple"
  114. @click="handleDelete"
  115. v-hasPermi="['supervise:pcsj:remove']"
  116. >删除</el-button
  117. >
  118. </el-col>
  119. <el-col :span="1.5">
  120. <el-button
  121. type="warning"
  122. plain
  123. icon="el-icon-download"
  124. size="mini"
  125. @click="handleExport"
  126. v-hasPermi="['supervise:pcsj:export']"
  127. >导出</el-button
  128. >
  129. </el-col>
  130. <right-toolbar
  131. :showSearch.sync="showSearch"
  132. @queryTable="getList"
  133. ></right-toolbar> -->
  134. </el-row>
  135. <el-table
  136. v-loading="loading"
  137. :data="pcsjList"
  138. @selection-change="handleSelectionChange"
  139. >
  140. <el-table-column type="selection" width="55" align="center" />
  141. <el-table-column label="文件名称" align="center" prop="name" />
  142. <el-table-column label="区县名称" align="center" prop="xzqmc" />
  143. <el-table-column
  144. label="图斑个数(个)"
  145. align="center"
  146. prop="spotsnumber"
  147. width="180"
  148. >
  149. <!-- <template slot-scope="scope">
  150. <span>{{ parseTime(scope.row.uploadtime, "{y}-{m}-{d}") }}</span>
  151. </template> -->
  152. </el-table-column>
  153. <el-table-column label="监测面积(亩)" align="center" prop="spotsarea" />
  154. <el-table-column label="文件大小(MB)" align="center" prop="spotssize">
  155. <template slot-scope="scope">
  156. <span>{{
  157. scope.row.spotssize
  158. ? (scope.row.spotssize / 1024 / 1024).toFixed(2)
  159. : ""
  160. }}</span>
  161. <!-- <span>{{ scope.row.spotssize }}</span> -->
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="录入时间" align="center" prop="filetime" />
  165. <el-table-column
  166. label="操作"
  167. align="center"
  168. class-name="small-padding fixed-width"
  169. >
  170. <template slot-scope="scope">
  171. <el-button
  172. size="mini"
  173. type="text"
  174. icon="el-icon-edit"
  175. @click="handleBrowse(scope.row)"
  176. :disabled="scope.row.readstatus != 0"
  177. v-hasPermi="['supervise:pcsj:list']"
  178. >浏览</el-button
  179. >
  180. <el-button
  181. size="mini"
  182. type="text"
  183. icon="el-icon-edit"
  184. @click="handleDownload(scope.row)"
  185. v-hasPermi="['supervise:pcsj:list']"
  186. >下载</el-button
  187. >
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. <pagination
  192. v-show="total > 0"
  193. :total="total"
  194. :page.sync="queryParams.pageNum"
  195. :limit.sync="queryParams.pageSize"
  196. @pagination="getList"
  197. />
  198. <!-- 添加或修改监管批次数据对话框 -->
  199. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  200. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  201. <el-form-item label="名称" prop="name">
  202. <el-input v-model="form.name" placeholder="请输入名称" />
  203. </el-form-item>
  204. <el-form-item label="上传用户" prop="uploaduser">
  205. <el-input v-model="form.uploaduser" placeholder="请输入上传用户" />
  206. </el-form-item>
  207. <el-form-item label="上传时间" prop="uploadtime">
  208. <el-date-picker
  209. clearable
  210. v-model="form.uploadtime"
  211. type="date"
  212. value-format="yyyy-MM-dd"
  213. placeholder="请选择上传时间"
  214. >
  215. </el-date-picker>
  216. </el-form-item>
  217. <el-form-item label="文件位置" prop="filepath">
  218. <el-input v-model="form.filepath" placeholder="请输入文件位置" />
  219. </el-form-item>
  220. <el-form-item label="shp位置" prop="shppath">
  221. <el-input v-model="form.shppath" placeholder="请输入shp位置" />
  222. </el-form-item>
  223. <el-form-item label="文件服务发布地址" prop="proxypath">
  224. <el-input
  225. v-model="form.proxypath"
  226. type="textarea"
  227. placeholder="请输入内容"
  228. />
  229. </el-form-item>
  230. <el-form-item label="解压文件地址" prop="unzippath">
  231. <el-input
  232. v-model="form.unzippath"
  233. type="textarea"
  234. placeholder="请输入内容"
  235. />
  236. </el-form-item>
  237. <el-form-item label="是否入库" prop="storage">
  238. <el-input v-model="form.storage" placeholder="请输入是否入库" />
  239. </el-form-item>
  240. <el-form-item label="行政区划代码" prop="xzqhdm">
  241. <el-input v-model="form.xzqhdm" placeholder="请输入行政区划代码" />
  242. </el-form-item>
  243. <el-form-item label="图斑数量" prop="spotsnumber">
  244. <el-input v-model="form.spotsnumber" placeholder="请输入图斑数量" />
  245. </el-form-item>
  246. <el-form-item label="图斑面积" prop="spotsarea">
  247. <el-input v-model="form.spotsarea" placeholder="请输入图斑面积" />
  248. </el-form-item>
  249. <el-form-item label="图斑大小" prop="spotssize">
  250. <el-input v-model="form.spotssize" placeholder="请输入图斑大小" />
  251. </el-form-item>
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button
  255. type="primary"
  256. v-hasPermi="['supervise:pcsj:upload']"
  257. @click="submitForm"
  258. >确 定</el-button
  259. >
  260. <el-button v-hasPermi="['supervise:pcsj:upload']" @click="cancel"
  261. >取 消</el-button
  262. >
  263. </div>
  264. </el-dialog>
  265. <el-dialog
  266. title="文件上传"
  267. :visible.sync="fileUploadDiv"
  268. width="400px"
  269. append-to-body
  270. >
  271. <el-upload
  272. class="upload-demo"
  273. drag
  274. :action="uploadFileUrl"
  275. :before-upload="handleBeforeUpload"
  276. :on-error="handleUploadError"
  277. :on-success="handleUploadSuccess"
  278. :limit="1"
  279. accept=".zip"
  280. :file-list="fileList"
  281. :show-file-list="true"
  282. multiple
  283. >
  284. <i class="el-icon-upload"></i>
  285. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  286. <div class="el-upload__tip" slot="tip">只能上传zip文件</div>
  287. </el-upload>
  288. </el-dialog>
  289. </div>
  290. </template>
  291. <script>
  292. import {
  293. listPcsj,
  294. getPcsj,
  295. delPcsj,
  296. addPcsj,
  297. updatePcsj,
  298. tiffUpload,
  299. } from "@/api/supervise/pcsj";
  300. import { listDept } from "@/api/system/dept";
  301. import Treeselect from "@riophae/vue-treeselect";
  302. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  303. export default {
  304. name: "Pcsj",
  305. components: { Treeselect },
  306. data() {
  307. return {
  308. // 遮罩层
  309. loading: false,
  310. // 选中数组
  311. ids: [],
  312. // 非单个禁用
  313. single: true,
  314. // 非多个禁用
  315. multiple: true,
  316. // 显示搜索条件
  317. showSearch: true,
  318. // 总条数
  319. total: 0,
  320. // 监管批次数据表格数据
  321. pcsjList: [
  322. // {
  323. // name: "", //文件名称
  324. // xzqdm: "", //区县名称
  325. // spotsnumber: "", //图斑个数
  326. // spotsarea: "", //监测面积(亩)
  327. // spotssize: "", //文件大小
  328. // filetime: "", //录入时间
  329. // },
  330. ],
  331. // 弹出层标题
  332. title: "",
  333. // 是否显示弹出层
  334. open: false,
  335. // 查询参数
  336. queryParams: {
  337. pageNum: 1,
  338. pageSize: 10,
  339. name: "", //文件名称
  340. xzqdm: undefined, //区县编码
  341. filetime: "", //录入时间
  342. readtime: "", //处理时间
  343. },
  344. // 表单参数
  345. form: {
  346. name: "1",
  347. uploaduser: "1",
  348. uploadtime: "1",
  349. filepath: "1",
  350. shppath: "1",
  351. proxypath: "1",
  352. unzippath: "1",
  353. filetype: "1",
  354. storage: "1",
  355. status: "1",
  356. xzqhdm: "1",
  357. spotsnumber: "1",
  358. spotsarea: "1",
  359. spotssize: "1",
  360. },
  361. // 表单校验
  362. rules: {},
  363. fileList: [],
  364. fileUploadDiv: false, //文件上传弹窗
  365. loading2: null,
  366. uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/uploadSpotZip",
  367. // 部门树选项
  368. deptOptions: [],
  369. selectedValues: [],
  370. };
  371. },
  372. created() {
  373. this.getList();
  374. this.getDept();
  375. },
  376. computed: {
  377. watchDeptId() {
  378. return this.queryParams.xzqdm;
  379. },
  380. },
  381. watch: {
  382. watchDeptId(newVal) {
  383. // console.log(newVal,'newValnewVal');
  384. },
  385. },
  386. methods: {
  387. getDept() {
  388. // 查询参数
  389. let queryParams = {
  390. deptId: this.$store.state.user.deptId,
  391. status: undefined,
  392. };
  393. listDept(queryParams).then((res) => {
  394. this.deptOptions = this.handleTree(res.data, "deptId");
  395. });
  396. },
  397. treeselecthange(value) {
  398. this.selectedValues = value.district;
  399. this.queryParams.xzqdm = value.district;
  400. },
  401. handleChange() {},
  402. /** 转换部门数据结构 */
  403. normalizer(node) {
  404. if (node.children && !node.children.length) {
  405. delete node.children;
  406. }
  407. return {
  408. id: node.district,
  409. label: node.deptName,
  410. children: node.children,
  411. };
  412. },
  413. fileUploadHandle() {
  414. console.log(this.uploadFileUrl);
  415. this.uploadFileUrl = this.uploadFileUrl;
  416. this.fileList = [];
  417. this.fileUploadDiv = true;
  418. },
  419. handleBeforeUpload(file) {
  420. this.$modal.loading("正在上传文件,请稍候...");
  421. return true;
  422. },
  423. // 上传失败
  424. handleUploadError(err) {
  425. this.$modal.msgError("上传文件失败,请重试");
  426. this.$modal.closeLoading();
  427. },
  428. // 上传成功回调
  429. handleUploadSuccess(res, file) {
  430. console.log("handleUploadSuccess");
  431. this.fileList = [];
  432. this.fileUploadDiv = false;
  433. this.$modal.closeLoading();
  434. this.$modal.msgSuccess(res.message);
  435. this.getList();
  436. },
  437. handleDownload(row) {
  438. const zipfile = row.proxypath + ".zip";
  439. window.open(`${zipfile}`);
  440. },
  441. /** 查询监管批次数据列表 */
  442. getList() {
  443. this.loading = true;
  444. listPcsj(this.queryParams).then((response) => {
  445. this.pcsjList = response.rows;
  446. this.total = response.total;
  447. this.loading = false;
  448. });
  449. },
  450. // 取消按钮
  451. cancel() {
  452. this.open = false;
  453. this.reset();
  454. },
  455. // 表单重置
  456. reset() {
  457. this.form = {
  458. id: null,
  459. name: null,
  460. uploaduser: null,
  461. uploadtime: null,
  462. filepath: null,
  463. shppath: null,
  464. proxypath: null,
  465. unzippath: null,
  466. filetype: null,
  467. storage: null,
  468. status: null,
  469. xzqhdm: null,
  470. xzqmc: null,
  471. spotsnumber: null,
  472. spotsarea: null,
  473. spotssize: null,
  474. };
  475. this.resetForm("form");
  476. },
  477. /** 搜索按钮操作 */
  478. handleQuery() {
  479. this.queryParams.pageNum = 1;
  480. this.getList();
  481. },
  482. /** 重置按钮操作 */
  483. resetQuery() {
  484. // this.resetForm("queryForm");
  485. // 查询参数
  486. (this.queryParams = {
  487. pageNum: 1,
  488. pageSize: 10,
  489. name: "", //文件名称
  490. xzqdm: "", //区县名称
  491. filetime: "", //录入时间
  492. readtime: "", //处理时间
  493. }),
  494. this.handleQuery();
  495. },
  496. // 多选框选中数据
  497. handleSelectionChange(selection) {
  498. this.ids = selection.map((item) => item.id);
  499. this.single = selection.length !== 1;
  500. this.multiple = !selection.length;
  501. },
  502. /** 新增按钮操作 */
  503. handleAdd() {
  504. this.reset();
  505. this.open = true;
  506. this.title = "添加监管批次数据";
  507. },
  508. // 浏览按钮
  509. handleBrowse(row) {
  510. this.$router.push({ path: "/remote/gdjc", query: { id: row.id } });
  511. },
  512. /** 修改按钮操作 */
  513. handleUpdate(row) {
  514. this.reset();
  515. const id = row.id || this.ids;
  516. getPcsj(id).then((response) => {
  517. this.form = response.data;
  518. this.open = true;
  519. this.title = "修改监管批次数据";
  520. });
  521. },
  522. /** 提交按钮 */
  523. submitForm() {
  524. this.$refs["form"].validate((valid) => {
  525. if (valid) {
  526. if (this.form.id != null) {
  527. updatePcsj(this.form).then((response) => {
  528. this.$modal.msgSuccess("修改成功");
  529. this.open = false;
  530. this.getList();
  531. });
  532. } else {
  533. addPcsj(this.form).then((response) => {
  534. this.$modal.msgSuccess("新增成功");
  535. this.open = false;
  536. this.getList();
  537. });
  538. }
  539. }
  540. });
  541. },
  542. /** 删除按钮操作 */
  543. handleDelete(row) {
  544. const ids = row.id || this.ids;
  545. this.$modal
  546. .confirm('是否确认删除监管批次数据编号为"' + ids + '"的数据项?')
  547. .then(function () {
  548. return delPcsj(ids);
  549. })
  550. .then(() => {
  551. this.getList();
  552. this.$modal.msgSuccess("删除成功");
  553. })
  554. .catch(() => {});
  555. },
  556. /** 导出按钮操作 */
  557. handleExport() {
  558. this.download(
  559. "supervise/pcsj/export",
  560. {
  561. ...this.queryParams,
  562. },
  563. `pcsj_${new Date().getTime()}.xlsx`
  564. );
  565. },
  566. },
  567. };
  568. </script>
  569. <style lang="scss" scoped>
  570. ::v-deep .el-form-item--medium .el-form-item__label {
  571. font-size: 11px;
  572. }
  573. ::v-deep .vue-treeselect {
  574. display: table-caption !important;
  575. width: 200px;
  576. }
  577. </style>