contrast.vue 9.0 KB

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