fileList.vue 16 KB

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