index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="字段名称" prop="lotattId">
  5. <el-input
  6. v-model="queryParams.lotattId"
  7. placeholder="请输入字段名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="字段描述" prop="lotattName">
  14. <el-input
  15. v-model="queryParams.lotattName"
  16. placeholder="请输入字段描述"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. v-hasPermi="['ams:config:add']"
  36. >新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['ams:config:edit']"
  47. >修改</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['ams:config:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="el-icon-download"
  65. size="mini"
  66. @click="handleExport"
  67. v-hasPermi="['ams:config:export']"
  68. >导出</el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="主键" align="center" prop="id" />
  75. <el-table-column label="字段名称" align="center" prop="lotattId" />
  76. <el-table-column label="字段描述" align="center" prop="lotattName" />
  77. <el-table-column label="是否必填" align="center" prop="requiredTag" />
  78. <el-table-column label="控件类型" align="center" prop="inputType" />
  79. <el-table-column label="输入范围" align="center" prop="inputScope" />
  80. <el-table-column label="默认值" align="center" prop="defaultValue" />
  81. <!--<el-table-column label="状态(0启用1禁用)" align="center" prop="status" />-->
  82. <el-table-column label="备注" align="center" prop="remark" />
  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="['ams:config: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="['ams:config:remove']"-->
  98. <!--&gt;删除</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. <!-- 添加或修改lotattConfig对话框 -->
  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="lotattId">
  113. <el-input v-model="form.lotattId" placeholder="请输入字段名称" />
  114. </el-form-item>
  115. <el-form-item label="字段描述" prop="lotattName">
  116. <el-input v-model="form.lotattName" placeholder="请输入字段描述" />
  117. </el-form-item>
  118. <el-form-item label="控件类型" prop="inputType">
  119. <el-select style="width: 100%" v-model="form.inputType" placeholder="请选择控件类型" clearable size="small">
  120. <el-option
  121. v-for="dict in inputTypeDict"
  122. :key="dict.value"
  123. :label="dict.label"
  124. :value="dict.value"
  125. />
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="是否必填" prop="requiredTag">
  129. <el-select style="width: 100%" v-model="form.requiredTag" placeholder="请选择是否必填" clearable size="small">
  130. <el-option
  131. v-for="dict in requiredTagDict"
  132. :key="dict.value"
  133. :label="dict.label"
  134. :value="dict.value"
  135. />
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item label="输入范围" prop="inputScope">
  139. <el-input v-model="form.inputScope" placeholder="请输入输入范围" />
  140. </el-form-item>
  141. <el-form-item label="默认值" prop="defaultValue">
  142. <el-input v-model="form.defaultValue" placeholder="请输入默认值" />
  143. </el-form-item>
  144. <el-form-item label="备注" prop="remark">
  145. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  146. </el-form-item>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button type="primary" @click="submitForm">确 定</el-button>
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. import { listConfig, getConfig, delConfig, addConfig, updateConfig } from "@/api/ams/config";
  157. import { inputType, requiredTag } from "@/utils/combo/dict";
  158. export default {
  159. name: "Config",
  160. data() {
  161. return {
  162. // 遮罩层
  163. loading: true,
  164. // 选中数组
  165. ids: [],
  166. // 非单个禁用
  167. single: true,
  168. // 非多个禁用
  169. multiple: true,
  170. // 显示搜索条件
  171. showSearch: true,
  172. // 总条数
  173. total: 0,
  174. // lotattConfig表格数据
  175. configList: [],
  176. // 弹出层标题
  177. title: "",
  178. // 是否显示弹出层
  179. open: false,
  180. // 查询参数
  181. queryParams: {
  182. pageNum: 1,
  183. pageSize: 10,
  184. lotattId: null,
  185. lotattName: null,
  186. status: null,
  187. },
  188. // 表单参数
  189. form: {},
  190. // 表单校验
  191. rules: {
  192. lotattId: [
  193. { required: true, message: "字段名称不能为空", trigger: "blur" }
  194. ],
  195. lotattName: [
  196. { required: true, message: "字段描述不能为空", trigger: "blur" }
  197. ],
  198. requiredTag: [
  199. { required: true, message: "是否必填不能为空", trigger: "change" }
  200. ],
  201. inputType: [
  202. { required: true, message: "控件类型不能为空", trigger: "change" }
  203. ],
  204. status: [
  205. { required: true, message: "状态(0启用1禁用)不能为空", trigger: "blur" }
  206. ],
  207. },
  208. inputTypeDict: inputType,
  209. requiredTagDict: requiredTag
  210. };
  211. },
  212. created() {
  213. this.getList();
  214. },
  215. methods: {
  216. /** 查询lotattConfig列表 */
  217. getList() {
  218. this.loading = true;
  219. listConfig(this.queryParams).then(response => {
  220. this.configList = response.rows;
  221. this.total = response.total;
  222. this.loading = false;
  223. });
  224. },
  225. // 取消按钮
  226. cancel() {
  227. this.open = false;
  228. this.reset();
  229. },
  230. // 表单重置
  231. reset() {
  232. this.form = {
  233. id: null,
  234. lotattId: null,
  235. lotattName: null,
  236. requiredTag: null,
  237. inputType: null,
  238. inputScope: null,
  239. defaultValue: null,
  240. status: "0",
  241. createBy: null,
  242. createTime: null,
  243. updateBy: null,
  244. updateTime: null,
  245. remark: null
  246. };
  247. this.resetForm("form");
  248. },
  249. /** 搜索按钮操作 */
  250. handleQuery() {
  251. this.queryParams.pageNum = 1;
  252. this.getList();
  253. },
  254. /** 重置按钮操作 */
  255. resetQuery() {
  256. this.resetForm("queryForm");
  257. this.handleQuery();
  258. },
  259. // 多选框选中数据
  260. handleSelectionChange(selection) {
  261. this.ids = selection.map(item => item.id)
  262. this.single = selection.length!==1
  263. this.multiple = !selection.length
  264. },
  265. /** 新增按钮操作 */
  266. handleAdd() {
  267. this.reset();
  268. this.open = true;
  269. this.title = "添加lotattConfig";
  270. },
  271. /** 修改按钮操作 */
  272. handleUpdate(row) {
  273. this.reset();
  274. const id = row.id || this.ids
  275. getConfig(id).then(response => {
  276. this.form = response.data;
  277. this.open = true;
  278. this.title = "修改lotattConfig";
  279. });
  280. },
  281. /** 提交按钮 */
  282. submitForm() {
  283. this.$refs["form"].validate(valid => {
  284. if (valid) {
  285. if (this.form.id != null) {
  286. updateConfig(this.form).then(response => {
  287. this.$modal.msgSuccess("修改成功");
  288. this.open = false;
  289. this.getList();
  290. });
  291. } else {
  292. addConfig(this.form).then(response => {
  293. this.$modal.msgSuccess("新增成功");
  294. this.open = false;
  295. this.getList();
  296. });
  297. }
  298. }
  299. });
  300. },
  301. /** 删除按钮操作 */
  302. handleDelete(row) {
  303. const ids = row.id || this.ids;
  304. this.$modal.confirm('是否确认删除lotattConfig编号为"' + ids + '"的数据项?').then(function() {
  305. return delConfig(ids);
  306. }).then(() => {
  307. this.getList();
  308. this.$modal.msgSuccess("删除成功");
  309. }).catch(() => {});
  310. },
  311. /** 导出按钮操作 */
  312. handleExport() {
  313. this.download('ams/config/export', {
  314. ...this.queryParams
  315. }, `config_${new Date().getTime()}.xlsx`)
  316. }
  317. }
  318. };
  319. </script>