index.vue 15 KB

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