fileList.vue 15 KB

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