index.vue 16 KB

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