index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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="engin_type">
  5. <el-select v-model="queryParams.enginType" placeholder="请选择所属工程">
  6. <el-option
  7. v-for="dict in dict.type.engin_type"
  8. :key="dict.value"
  9. :label="dict.label"
  10. :value="dict.value"
  11. ></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="材质名称" prop="name">
  15. <el-input
  16. v-model="queryParams.name"
  17. placeholder="请输入材质名称"
  18. clearable
  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="['zdsz:enginMaterialQuality:add']"
  36. >新增
  37. </el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="success"
  42. plain
  43. icon="el-icon-edit"
  44. size="mini"
  45. :disabled="single"
  46. @click="handleUpdate"
  47. v-hasPermi="['zdsz:enginMaterialQuality:edit']"
  48. >修改
  49. </el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="danger"
  54. plain
  55. icon="el-icon-delete"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleDelete"
  59. v-hasPermi="['zdsz:enginMaterialQuality:remove']"
  60. >删除
  61. </el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="warning"
  66. plain
  67. icon="el-icon-download"
  68. size="mini"
  69. @click="handleExport"
  70. v-hasPermi="['zdsz:enginMaterialQuality:export']"
  71. >导出
  72. </el-button>
  73. </el-col>
  74. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  75. </el-row>
  76. <el-table v-loading="loading" :data="enginMaterialQualityList" @selection-change="handleSelectionChange">
  77. <el-table-column type="selection" width="55" align="center"/>
  78. <!-- <el-table-column label="id" align="center" prop="id" v-if="true"/>-->
  79. <el-table-column label="工程类型" align="center" prop="enginType">
  80. <template slot-scope="scope">
  81. <dict-tag v-for="item in scope.row.enginType.split(',')" :options="dict.type.engin_type" :value="item"/>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="材质名称" align="center" prop="name" />
  85. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  86. <template slot-scope="scope">
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-edit"
  91. @click="handleUpdate(scope.row)"
  92. v-hasPermi="['zdsz:enginMaterialQuality:edit']"
  93. >修改
  94. </el-button>
  95. <el-button
  96. size="mini"
  97. type="text"
  98. icon="el-icon-delete"
  99. @click="handleDelete(scope.row)"
  100. v-hasPermi="['zdsz:enginMaterialQuality:remove']"
  101. >删除
  102. </el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <pagination
  107. v-show="total>0"
  108. :total="total"
  109. :page.sync="queryParams.pageNum"
  110. :limit.sync="queryParams.pageSize"
  111. @pagination="getList"
  112. />
  113. <!-- 添加或修改工程材质对话框 -->
  114. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  115. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  116. <el-form-item label="所属工程" prop="enginType">
  117. <el-select v-model="form.enginType" placeholder="请选择所属工程" filterable clearable multiple
  118. style="width: 100%">
  119. <el-option
  120. v-for="dict in dict.type.engin_type"
  121. :key="dict.value"
  122. :label="dict.label"
  123. :value="dict.value"
  124. ></el-option>
  125. </el-select>
  126. </el-form-item>
  127. <el-form-item label="材质名称" prop="name">
  128. <el-input v-model="form.name" placeholder="请输入材质名称" maxlength="50"/>
  129. </el-form-item>
  130. </el-form>
  131. <div slot="footer" class="dialog-footer">
  132. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  133. <el-button @click="cancel">取 消</el-button>
  134. </div>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import {
  140. listEnginMaterialQuality,
  141. getEnginMaterialQuality,
  142. delEnginMaterialQuality,
  143. addEnginMaterialQuality,
  144. updateEnginMaterialQuality
  145. } from "@/api/zdsz/enginMaterialQuality";
  146. export default {
  147. name: "EnginMaterialQuality",
  148. dicts: ['engin_type'],
  149. data() {
  150. return {
  151. // 按钮loading
  152. buttonLoading: false,
  153. // 遮罩层
  154. loading: true,
  155. // 选中数组
  156. ids: [],
  157. // 非单个禁用
  158. single: true,
  159. // 非多个禁用
  160. multiple: true,
  161. // 显示搜索条件
  162. showSearch: true,
  163. // 总条数
  164. total: 0,
  165. // 工程材质表格数据
  166. enginMaterialQualityList: [],
  167. // 弹出层标题
  168. title: "",
  169. // 是否显示弹出层
  170. open: false,
  171. // 查询参数
  172. queryParams: {
  173. pageNum: 1,
  174. pageSize: 10,
  175. enginType: undefined,
  176. name: undefined,
  177. },
  178. // 表单参数
  179. form: {},
  180. // 表单校验
  181. rules: {
  182. id: [
  183. {required: true, message: "不能为空", trigger: "blur"}
  184. ],
  185. enginType: [
  186. {required: true, message: "所属工程不能为空", trigger: "change"}
  187. ],
  188. name: [
  189. {required: true, message: "材质名称不能为空", trigger: "blur"}
  190. ],
  191. }
  192. };
  193. },
  194. created() {
  195. this.getList();
  196. },
  197. methods: {
  198. /** 查询工程材质列表 */
  199. getList() {
  200. this.loading = true;
  201. listEnginMaterialQuality(this.queryParams).then(response => {
  202. this.enginMaterialQualityList = response.rows;
  203. this.total = response.total;
  204. this.loading = false;
  205. });
  206. },
  207. // 取消按钮
  208. cancel() {
  209. this.open = false;
  210. this.reset();
  211. },
  212. // 表单重置
  213. reset() {
  214. this.form = {
  215. id: undefined,
  216. enginType: undefined,
  217. name: undefined,
  218. delFlag: undefined,
  219. createBy: undefined,
  220. createTime: undefined,
  221. updateBy: undefined,
  222. updateTime: undefined
  223. };
  224. this.resetForm("form");
  225. },
  226. /** 搜索按钮操作 */
  227. handleQuery() {
  228. this.queryParams.pageNum = 1;
  229. this.getList();
  230. },
  231. /** 重置按钮操作 */
  232. resetQuery() {
  233. this.queryParams= {
  234. pageNum: 1,
  235. pageSize: 10,
  236. enginType: undefined,
  237. name: undefined,
  238. },
  239. this.resetForm("queryForm");
  240. this.handleQuery();
  241. },
  242. // 多选框选中数据
  243. handleSelectionChange(selection) {
  244. this.ids = selection.map(item => item.id)
  245. this.single = selection.length !== 1
  246. this.multiple = !selection.length
  247. },
  248. /** 新增按钮操作 */
  249. handleAdd() {
  250. this.reset();
  251. this.open = true;
  252. this.title = "添加工程材质";
  253. },
  254. /** 修改按钮操作 */
  255. handleUpdate(row) {
  256. this.loading = true;
  257. this.reset();
  258. const id = row.id || this.ids
  259. getEnginMaterialQuality(id).then(response => {
  260. this.loading = false;
  261. this.form = response.data;
  262. this.form.enginType = this.form.enginType.split(",")
  263. this.open = true;
  264. this.title = "修改工程材质";
  265. });
  266. },
  267. /** 提交按钮 */
  268. submitForm() {
  269. this.$refs["form"].validate(valid => {
  270. if (valid) {
  271. this.buttonLoading = true;
  272. let eng = this.form.enginType
  273. if (this.form.id != null) {
  274. this.form.enginType = this.form.enginType.join()
  275. updateEnginMaterialQuality(this.form).then(response => {
  276. this.$modal.msgSuccess("修改成功");
  277. this.open = false;
  278. this.getList();
  279. }).finally(() => {
  280. this.buttonLoading = false;
  281. }).catch(e => {
  282. this.form.enginType = eng
  283. });
  284. } else {
  285. this.form.enginType = this.form.enginType.join()
  286. addEnginMaterialQuality(this.form).then(response => {
  287. this.$modal.msgSuccess("新增成功");
  288. this.open = false;
  289. this.getList();
  290. }).finally(() => {
  291. this.buttonLoading = false;
  292. }).catch(e => {
  293. this.form.enginType = eng
  294. });
  295. }
  296. }
  297. });
  298. },
  299. /** 删除按钮操作 */
  300. handleDelete(row) {
  301. const ids = row.id || this.ids;
  302. this.$modal.confirm('是否确认删除?').then(() => {
  303. this.loading = true;
  304. return delEnginMaterialQuality(ids);
  305. }).then(() => {
  306. this.loading = false;
  307. this.getList();
  308. this.$modal.msgSuccess("删除成功");
  309. }).catch(() => {
  310. }).finally(() => {
  311. this.loading = false;
  312. });
  313. },
  314. /** 导出按钮操作 */
  315. handleExport() {
  316. this.download('zdsz/enginMaterialQuality/export', {
  317. ...this.queryParams
  318. }, `enginMaterialQuality_${new Date().getTime()}.xlsx`)
  319. }
  320. }
  321. };
  322. </script>