fileList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. v-if="type !== '2'"
  5. :model="queryParams"
  6. ref="queryForm"
  7. size="small"
  8. :inline="true"
  9. v-show="showSearch"
  10. label-width="70px"
  11. >
  12. <el-form-item label="文件名称" prop="fileName">
  13. <el-input
  14. v-model.trim="queryParams.fileName"
  15. placeholder="请输入文件名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="文件类别" prop="fileType">
  21. <el-select v-model="queryParams.fileType" placeholder="全部" clearable>
  22. <el-option
  23. v-for="dict in dict.type.file_type"
  24. :key="dict.value"
  25. :label="dict.label"
  26. :value="dict.value"
  27. />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button
  32. type="primary"
  33. icon="el-icon-search"
  34. size="mini"
  35. @click="handleQuery"
  36. >搜索</el-button
  37. >
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  39. >重置</el-button
  40. >
  41. </el-form-item>
  42. </el-form>
  43. <el-row :gutter="10" class="mb8" v-if="type !== '2'">
  44. <el-col :span="1.5">
  45. <el-button
  46. type="primary"
  47. plain
  48. icon="el-icon-plus"
  49. size="mini"
  50. @click="handleAdd"
  51. v-hasPermi="['invest:information:add']"
  52. >新增</el-button
  53. >
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="success"
  58. plain
  59. icon="el-icon-edit"
  60. size="mini"
  61. :disabled="single"
  62. @click="handleUpdate"
  63. v-hasPermi="['invest:information:edit']"
  64. >修改</el-button
  65. >
  66. </el-col>
  67. <el-col :span="1.5">
  68. <el-button
  69. type="danger"
  70. plain
  71. icon="el-icon-delete"
  72. size="mini"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. v-hasPermi="['invest:information:remove']"
  76. >删除</el-button
  77. >
  78. </el-col>
  79. <el-col :span="1.5">
  80. <el-button
  81. type="warning"
  82. plain
  83. icon="el-icon-download"
  84. size="mini"
  85. @click="handleExport"
  86. v-hasPermi="['invest:information:export']"
  87. >导出</el-button
  88. >
  89. </el-col>
  90. <right-toolbar
  91. :showSearch.sync="showSearch"
  92. @queryTable="getList"
  93. ></right-toolbar>
  94. </el-row>
  95. <el-table
  96. class="tableWrapper"
  97. v-loading="loading"
  98. border
  99. :data="informationList"
  100. @selection-change="handleSelectionChange"
  101. >
  102. <el-table-column
  103. v-if="type === '1'"
  104. type="selection"
  105. width="55"
  106. align="center"
  107. />
  108. <!-- <el-table-column label="主键ID" align="center" prop="id" /> -->
  109. <el-table-column
  110. label="文件名称"
  111. width="300"
  112. align="center"
  113. prop="fileName"
  114. >
  115. <template slot-scope="scope">
  116. <div :title="scope.row.fileName">
  117. {{ scope.row.fileName }}
  118. </div>
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. label="文件类别"
  123. width="160"
  124. align="center"
  125. prop="fileType"
  126. >
  127. <template slot-scope="scope">
  128. <dict-tag
  129. :options="dict.type.file_type"
  130. :value="scope.row.fileType"
  131. />
  132. </template>
  133. </el-table-column>
  134. <el-table-column
  135. label="项目名称"
  136. width="200"
  137. align="center"
  138. prop="tProjectPool.projectName"
  139. >
  140. <template slot-scope="scope">
  141. <div :title="scope.row.tProjectPool.projectName">
  142. {{ scope.row.tProjectPool.projectName }}
  143. </div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="项目阶段" align="center" prop="projectStage">
  147. <template slot-scope="scope">
  148. <dict-tag
  149. :options="dict.type.project_stage"
  150. :value="scope.row.projectStage"
  151. />
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="备注" width="120" align="center" prop="remark">
  155. <template slot-scope="scope">
  156. <div :title="scope.row.remark">
  157. {{ scope.row.remark }}
  158. </div>
  159. </template>
  160. </el-table-column>
  161. <el-table-column
  162. label="创建人"
  163. width="120"
  164. align="center"
  165. prop="createBy"
  166. >
  167. <template slot-scope="scope">
  168. <div :title="scope.row.createBy">
  169. {{ scope.row.createBy }}
  170. </div>
  171. </template>
  172. </el-table-column>
  173. <el-table-column
  174. label="创建时间"
  175. width="160"
  176. align="center"
  177. prop="createTime"
  178. >
  179. <template slot-scope="scope">
  180. <div :title="scope.row.createTime">
  181. {{ scope.row.createTime }}
  182. </div>
  183. </template>
  184. </el-table-column>
  185. <el-table-column
  186. width="120"
  187. fixed="right"
  188. label="操作"
  189. align="center"
  190. class-name="small-padding fixed-width"
  191. >
  192. <template slot-scope="scope">
  193. <el-button
  194. size="mini"
  195. type="text"
  196. icon="el-icon-edit"
  197. @click="handleUpdate(scope.row)"
  198. v-hasPermi="['invest:information:edit']"
  199. >修改</el-button
  200. >
  201. <el-button
  202. class="custom-red-color"
  203. size="mini"
  204. type="text"
  205. icon="el-icon-delete"
  206. @click="handleDelete(scope.row)"
  207. v-hasPermi="['invest:information:remove']"
  208. >删除</el-button
  209. >
  210. </template>
  211. </el-table-column>
  212. </el-table>
  213. <pagination
  214. v-show="total > 0"
  215. :total="total"
  216. :page.sync="queryParams.pageNum"
  217. :limit.sync="queryParams.pageSize"
  218. @pagination="getList"
  219. />
  220. <!-- 添加或修改文件资料对话框 -->
  221. <el-dialog
  222. :title="title"
  223. :visible.sync="open"
  224. width="1000px"
  225. append-to-body
  226. >
  227. <el-form
  228. class="special-el-form"
  229. ref="fileForm"
  230. :model="form"
  231. :rules="rules"
  232. label-width="90px"
  233. >
  234. <el-form-item label="文件名称" prop="fileName">
  235. <el-input
  236. maxlength="100"
  237. v-model="form.fileName"
  238. placeholder="请输入文件名称"
  239. />
  240. </el-form-item>
  241. <el-form-item label="文件类别" prop="fileType">
  242. <el-select v-model="form.fileType" placeholder="请选择文件类别">
  243. <el-option
  244. v-for="dict in dict.type.file_type"
  245. :key="dict.value"
  246. :label="dict.label"
  247. :value="dict.value"
  248. ></el-option>
  249. </el-select>
  250. </el-form-item>
  251. <el-form-item label="项目名称" prop="projectName">
  252. <div
  253. class="el-input__inner inputSimulation yichu1"
  254. @click="handleProjectItem"
  255. :class="{ show_disabled: pageType === '1' }"
  256. :title="form.projectName"
  257. >
  258. {{ form.projectName ? form.projectName : "请选择项目" }}
  259. </div>
  260. <projectItem
  261. ref="projectItem"
  262. @getProjectInfo="getProjectInfo"
  263. ></projectItem>
  264. </el-form-item>
  265. <el-form-item label="项目阶段" prop="projectStage">
  266. <el-select v-model="form.projectStage" disabled placeholder="">
  267. <el-option
  268. v-for="dict in dict.type.project_stage"
  269. :key="dict.value"
  270. :label="dict.label"
  271. :value="dict.value"
  272. />
  273. </el-select>
  274. </el-form-item>
  275. <!-- <el-form-item label="会议编号" prop="fileBusinessId">
  276. <div
  277. class="el-input__inner inputSimulation"
  278. @click="handleMeetingItem"
  279. >
  280. {{ form.meetingTheme ? form.meetingTheme : "请选择会议" }}
  281. </div>
  282. <meetingItem
  283. ref="meetingItem"
  284. @getMeetingInfo="getMeetingInfo"
  285. ></meetingItem>
  286. </el-form-item> -->
  287. <el-form-item label="文件" prop="listFile" class="special-el-form-item">
  288. <fileItem
  289. ref="fileItems"
  290. :id="form.id"
  291. @getFileList="getFileList"
  292. ></fileItem>
  293. </el-form-item>
  294. <el-form-item label="备注" prop="remark" class="special-el-form-item">
  295. <el-input
  296. maxlength="200"
  297. rows="4"
  298. type="textarea"
  299. v-model="form.remark"
  300. placeholder="请输入备注"
  301. />
  302. </el-form-item>
  303. </el-form>
  304. <div slot="footer" class="dialog-footer">
  305. <el-button type="primary" @click="submitForm" v-preventReClick
  306. >确 定</el-button
  307. >
  308. <el-button @click="cancel">取 消</el-button>
  309. </div>
  310. </el-dialog>
  311. </div>
  312. </template>
  313. <script>
  314. import {
  315. listInformation,
  316. getInformation,
  317. delInformation,
  318. addInformation,
  319. updateInformation,
  320. } from "@/api/invest/information";
  321. import projectItem from "./projectItem";
  322. import fileItem from "./fileItem";
  323. import meetingItem from "./meetingItem";
  324. export default {
  325. props: {
  326. type: {
  327. type: String,
  328. default: "1", //1=显示全部列表 2=显示某项目下的详情列表
  329. },
  330. projectId: {
  331. type: String,
  332. },
  333. },
  334. components: { projectItem, fileItem, meetingItem },
  335. dicts: ["file_type", "project_stage"],
  336. data() {
  337. const validateLogo = (rule, value, callback) => {
  338. if (this.fileList.length <= 0) {
  339. callback(new Error("请上传文件"));
  340. } else {
  341. callback();
  342. }
  343. };
  344. return {
  345. pageType: null,
  346. id: "",
  347. fileList: [],
  348. // 遮罩层
  349. loading: true,
  350. // 选中数组
  351. ids: [],
  352. idsName: [],
  353. // 非单个禁用
  354. single: true,
  355. // 非多个禁用
  356. multiple: true,
  357. // 显示搜索条件
  358. showSearch: true,
  359. // 总条数
  360. total: 0,
  361. // 文件资料表格数据
  362. informationList: [],
  363. // 弹出层标题
  364. title: "",
  365. // 是否显示弹出层
  366. open: false,
  367. // 查询参数
  368. queryParams: {
  369. pageNum: 1,
  370. pageSize: 10,
  371. fileName: null,
  372. fileType: null,
  373. projectStage: null,
  374. fileBusinessId: null,
  375. orderByColumn: "createTime",
  376. isAsc: "desc",
  377. },
  378. // 表单参数
  379. form: {
  380. id: null,
  381. fileName: null,
  382. fileType: null,
  383. projectPoolId: null,
  384. projectName: null,
  385. projectStage: null,
  386. meetingTheme: null,
  387. fileBusinessId: null,
  388. delFlag: null,
  389. remark: null,
  390. createBy: null,
  391. createTime: null,
  392. updateBy: null,
  393. updateTime: null,
  394. listFile: null,
  395. },
  396. // 表单校验
  397. rules: {
  398. fileName: [{ required: true, trigger: "blur", message: "请输入" }],
  399. projectName: [{ required: true, trigger: "blur", message: "请选择" }],
  400. fileType: [{ required: true, trigger: "change", message: "请选择" }],
  401. listFile: [{ required: true, validator: validateLogo }],
  402. },
  403. };
  404. },
  405. created() {
  406. if (this.projectId) {
  407. this.queryParams.projectPoolId = this.projectId;
  408. }
  409. this.getList();
  410. },
  411. methods: {
  412. // 获取公司信息
  413. getProjectInfo(info) {
  414. if (info.length > 0) {
  415. this.form.projectPoolId = info[0].id;
  416. this.form.projectName = info[0].projectName;
  417. this.form.projectStage = info[0].projectStage;
  418. this.form.projectState = info[0].projectState;
  419. this.$refs.fileForm.clearValidate(["projectName"]);
  420. }
  421. },
  422. //展示人员
  423. handleProjectItem() {
  424. this.$refs.projectItem.showProjectItem = true;
  425. },
  426. // 获取会议信息
  427. // getMeetingInfo(info) {
  428. // if (info.length > 0) {
  429. // this.form.fileBusinessId = info[0].id;
  430. // this.form.meetingTheme = info[0].meetingTheme;
  431. // }
  432. // },
  433. handleMeetingItem() {
  434. this.$refs.meetingItem.showMeetingItem = true;
  435. },
  436. // 获取fileList
  437. getFileList(fileList) {
  438. this.fileList = fileList;
  439. if (fileList.length > 0) {
  440. this.$refs.fileForm.clearValidate(["listFile"]);
  441. }
  442. },
  443. /** 查询文件资料列表 */
  444. getList() {
  445. this.loading = true;
  446. if (this.projectId) {
  447. this.queryParams.projectPoolId = this.projectId;
  448. }
  449. listInformation(this.queryParams).then((response) => {
  450. this.informationList = response.rows;
  451. this.total = response.total;
  452. this.loading = false;
  453. });
  454. },
  455. // 取消按钮
  456. cancel() {
  457. this.open = false;
  458. this.reset();
  459. },
  460. // 表单重置
  461. reset() {
  462. this.form = {
  463. id: null,
  464. fileName: null,
  465. fileType: null,
  466. projectPoolId: null,
  467. projectName: null,
  468. projectStage: null,
  469. meetingTheme: null,
  470. fileBusinessId: null,
  471. delFlag: null,
  472. remark: null,
  473. createBy: null,
  474. createTime: null,
  475. updateBy: null,
  476. updateTime: null,
  477. listFile: null,
  478. };
  479. this.resetForm("form");
  480. },
  481. /** 搜索按钮操作 */
  482. handleQuery() {
  483. this.queryParams.pageNum = 1;
  484. this.getList();
  485. },
  486. /** 重置按钮操作 */
  487. resetQuery() {
  488. this.resetForm("queryForm");
  489. this.queryParams.orderByColumn = "createTime";
  490. this.queryParams.isAsc = "desc";
  491. this.handleQuery();
  492. },
  493. // 多选框选中数据
  494. handleSelectionChange(selection) {
  495. this.ids = selection.map((item) => item.id);
  496. this.idsName = selection.map((item) => item.fileName);
  497. this.single = selection.length !== 1;
  498. this.multiple = !selection.length;
  499. },
  500. /** 新增按钮操作 */
  501. handleAdd(projectId) {
  502. let that = this;
  503. this.reset();
  504. if (projectId && typeof projectId === "string") {
  505. this.pageType = "1";
  506. let projectItemMessage = this.$store.getters.projectItemMessage;
  507. this.form.projectPoolId = projectItemMessage.id;
  508. this.form.projectName = projectItemMessage.projectName;
  509. this.form.projectStage = projectItemMessage.projectStage;
  510. }
  511. this.open = true;
  512. this.title = "添加文件资料";
  513. setTimeout(() => {
  514. that.$refs.fileItems.fileList = [];
  515. }, 200);
  516. },
  517. /** 修改按钮操作 */
  518. handleUpdate(row) {
  519. let that = this;
  520. this.reset();
  521. const id = row.id || this.ids;
  522. getInformation(id).then((response) => {
  523. this.form = response.data;
  524. this.form.projectName = response.data.tProjectPool.projectName;
  525. this.form.projectStage = response.data.tProjectPool.projectStage;
  526. this.open = true;
  527. this.title = "修改文件资料";
  528. setTimeout(() => {
  529. this.$refs.fileItems.fileList = [];
  530. this.$refs.fileItems.getListFileBusinessId(id);
  531. }, 300);
  532. });
  533. },
  534. /** 提交按钮 */
  535. submitForm() {
  536. //取消该项校验
  537. // console.log(this.fileList.length > 0);
  538. this.$refs["fileForm"].validate((valid) => {
  539. if (valid) {
  540. this.form.listFile = this.fileList;
  541. if (this.form.id != null) {
  542. updateInformation(this.form).then((response) => {
  543. this.$modal.msgSuccess("修改成功");
  544. this.open = false;
  545. this.getList();
  546. });
  547. } else {
  548. addInformation(this.form).then((response) => {
  549. this.$modal.msgSuccess("新增成功");
  550. this.open = false;
  551. this.getList();
  552. });
  553. }
  554. }
  555. });
  556. },
  557. /** 删除按钮操作 */
  558. handleDelete(row) {
  559. const ids = row.id || this.ids;
  560. const idsName = row.fileName ? row.fileName : this.idsName;
  561. this.$modal
  562. .confirm('是否确认删除"' + idsName + '"?')
  563. .then(function () {
  564. return delInformation(ids);
  565. })
  566. .then(() => {
  567. this.getList();
  568. this.$modal.msgSuccess("删除成功");
  569. })
  570. .catch(() => {});
  571. },
  572. /** 导出按钮操作 */
  573. handleExport() {
  574. this.download(
  575. "invest/information/export",
  576. {
  577. ...this.queryParams,
  578. },
  579. `information_${new Date().getTime()}.xlsx`
  580. );
  581. },
  582. },
  583. };
  584. </script>