index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="描述" prop="describe">
  13. <el-input
  14. v-model="queryParams.describe"
  15. placeholder="请输入描述"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="primary"
  29. plain
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. v-hasPermi="['doc:radmon:add']"
  34. >新增</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="success"
  39. plain
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. v-hasPermi="['doc:radmon:edit']"
  45. >修改</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="danger"
  50. plain
  51. icon="el-icon-delete"
  52. size="mini"
  53. :disabled="multiple"
  54. @click="handleDelete"
  55. v-hasPermi="['doc:radmon:remove']"
  56. >删除</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="warning"
  61. plain
  62. icon="el-icon-download"
  63. size="mini"
  64. @click="handleExport"
  65. v-hasPermi="['doc:radmon:export']"
  66. >导出</el-button>
  67. </el-col>
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table v-loading="loading" :data="radmonList" @selection-change="handleSelectionChange">
  71. <el-table-column type="selection" width="55" align="center" />
  72. <el-table-column label="序号" align="center" prop="id" />
  73. <el-table-column label="名称" align="center" prop="name" />
  74. <el-table-column label="描述" align="center" prop="describe" />
  75. <el-table-column label="类型" align="center" prop="type" />
  76. <el-table-column label="文件" align="center" prop="filePath" >
  77. <template slot-scope="scope">
  78. <el-link :href="`${baseUrl}${scope.row.filePath}`" :underline="false" target="_blank">
  79. <span class="el-icon-document"> {{ getFileName(scope.row.filePath) }} </span>
  80. </el-link>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-edit"
  89. @click="handleUpdate(scope.row)"
  90. v-hasPermi="['doc:radmon:edit']"
  91. >修改</el-button>
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-delete"
  96. @click="handleDelete(scope.row)"
  97. v-hasPermi="['doc:radmon:remove']"
  98. >删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination
  103. v-show="total>0"
  104. :total="total"
  105. :page.sync="queryParams.pageNum"
  106. :limit.sync="queryParams.pageSize"
  107. @pagination="getList"
  108. />
  109. <!-- 添加或修改随机资料对话框 -->
  110. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  111. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  112. <el-form-item label="名称" prop="name">
  113. <el-input v-model="form.name" placeholder="请输入名称" />
  114. </el-form-item>
  115. <el-form-item label="描述" prop="describe">
  116. <el-input v-model="form.describe" placeholder="请输入描述" />
  117. </el-form-item>
  118. <el-form-item label="文件">
  119. <file-upload v-model="form.filePath"/>
  120. </el-form-item>
  121. </el-form>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="submitForm">确 定</el-button>
  124. <el-button @click="cancel">取 消</el-button>
  125. </div>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import { listRadmon, getRadmon, delRadmon, addRadmon, updateRadmon } from "@/api/doc/radmon";
  131. export default {
  132. name: "Radmon",
  133. data() {
  134. return {
  135. // 遮罩层
  136. loading: true,
  137. // 选中数组
  138. ids: [],
  139. // 非单个禁用
  140. single: true,
  141. // 非多个禁用
  142. multiple: true,
  143. // 显示搜索条件
  144. showSearch: true,
  145. // 总条数
  146. total: 0,
  147. // 随机资料表格数据
  148. radmonList: [],
  149. // 弹出层标题
  150. title: "",
  151. // 是否显示弹出层
  152. open: false,
  153. // 查询参数
  154. queryParams: {
  155. pageNum: 1,
  156. pageSize: 10,
  157. name: null,
  158. describe: null,
  159. type: null,
  160. filePath: null,
  161. },
  162. // 表单参数
  163. form: {},
  164. // 表单校验
  165. rules: {
  166. },
  167. baseUrl: process.env.VUE_APP_BASE_API,
  168. };
  169. },
  170. created() {
  171. this.getList();
  172. },
  173. methods: {
  174. /** 查询随机资料列表 */
  175. getList() {
  176. this.loading = true;
  177. listRadmon(this.queryParams).then(response => {
  178. this.radmonList = response.rows;
  179. this.total = response.total;
  180. this.loading = false;
  181. });
  182. },
  183. // 取消按钮
  184. cancel() {
  185. this.open = false;
  186. this.reset();
  187. },
  188. // 表单重置
  189. reset() {
  190. this.form = {
  191. id: null,
  192. name: null,
  193. describe: null,
  194. type: null,
  195. filePath: null,
  196. createBy: null,
  197. createTime: null,
  198. updateBy: null,
  199. updateTime: null
  200. };
  201. this.resetForm("form");
  202. },
  203. /** 搜索按钮操作 */
  204. handleQuery() {
  205. this.queryParams.pageNum = 1;
  206. this.getList();
  207. },
  208. /** 重置按钮操作 */
  209. resetQuery() {
  210. this.resetForm("queryForm");
  211. this.handleQuery();
  212. },
  213. // 多选框选中数据
  214. handleSelectionChange(selection) {
  215. this.ids = selection.map(item => item.id)
  216. this.single = selection.length!==1
  217. this.multiple = !selection.length
  218. },
  219. /** 新增按钮操作 */
  220. handleAdd() {
  221. this.reset();
  222. this.open = true;
  223. this.title = "添加随机资料";
  224. },
  225. /** 修改按钮操作 */
  226. handleUpdate(row) {
  227. this.reset();
  228. const id = row.id || this.ids
  229. getRadmon(id).then(response => {
  230. this.form = response.data;
  231. this.open = true;
  232. this.title = "修改随机资料";
  233. });
  234. },
  235. /** 提交按钮 */
  236. submitForm() {
  237. this.$refs["form"].validate(valid => {
  238. if (valid) {
  239. if (this.form.id != null) {
  240. updateRadmon(this.form).then(response => {
  241. this.$modal.msgSuccess("修改成功");
  242. this.open = false;
  243. this.getList();
  244. });
  245. } else {
  246. addRadmon(this.form).then(response => {
  247. this.$modal.msgSuccess("新增成功");
  248. this.open = false;
  249. this.getList();
  250. });
  251. }
  252. }
  253. });
  254. },
  255. /** 删除按钮操作 */
  256. handleDelete(row) {
  257. const ids = row.id || this.ids;
  258. this.$modal.confirm('是否确认删除随机资料编号为"' + ids + '"的数据项?').then(function() {
  259. return delRadmon(ids);
  260. }).then(() => {
  261. this.getList();
  262. this.$modal.msgSuccess("删除成功");
  263. }).catch(() => {});
  264. },
  265. /** 导出按钮操作 */
  266. handleExport() {
  267. this.download('doc/radmon/export', {
  268. ...this.queryParams
  269. }, `radmon_${new Date().getTime()}.xlsx`)
  270. },
  271. getFileName(name) {
  272. if (name.lastIndexOf("/") > -1) {
  273. return name.slice(name.lastIndexOf("/") + 1);
  274. } else {
  275. return "";
  276. }
  277. },
  278. }
  279. };
  280. </script>