index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="队伍" prop="postId">
  14. <el-select v-model="queryParams.postId" clearable placeholder="请选择队伍" :disabled="postName.indexOf('xx') > -1">
  15. <el-option
  16. v-for="item in postOptions"
  17. :key="item.postId"
  18. :label="item.postName"
  19. :value="item.postId"
  20. ></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row :gutter="10" class="mb8">
  29. <el-col :span="1.5">
  30. <el-button
  31. type="primary"
  32. plain
  33. icon="el-icon-plus"
  34. size="mini"
  35. @click="handleAdd"
  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. >修改</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="danger"
  51. plain
  52. icon="el-icon-delete"
  53. size="mini"
  54. :disabled="multiple"
  55. @click="handleDelete"
  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. :loading="exportLoading"
  65. @click="handleExport"
  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="cadList" @selection-change="handleSelectionChange">
  71. <el-table-column type="selection" width="55" align="center" />
  72. <el-table-column label="主键" align="center" prop="id" v-if="true"/>
  73. <el-table-column label="名称" align="center" prop="name" />
  74. <el-table-column label="队伍id" align="center" prop="postId" >
  75. <template slot-scope="scope">
  76. <dict-post :options="postOptions" :value="scope.row.ranks"/>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="备注" align="center" prop="remark" />
  80. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  81. <template slot-scope="scope">
  82. <el-button
  83. size="mini"
  84. type="text"
  85. icon="el-icon-edit"
  86. @click="handleUpdate(scope.row)"
  87. >修改</el-button>
  88. <el-button
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. >删除</el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <pagination
  98. v-show="total>0"
  99. :total="total"
  100. :page.sync="queryParams.pageNum"
  101. :limit.sync="queryParams.pageSize"
  102. @pagination="getList"
  103. />
  104. <!-- 添加或修改cad图纸对话框 -->
  105. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  106. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  107. <el-form-item label="名称" prop="name">
  108. <el-input v-model="form.name" placeholder="请输入名称" />
  109. </el-form-item>
  110. <el-form-item label="队伍" prop="postId">
  111. <el-select v-model="form.postId" clearable placeholder="请选择队伍">
  112. <el-option
  113. v-for="item in postOptions"
  114. :key="item.postId"
  115. :label="item.postName"
  116. :value="item.postId"
  117. ></el-option>
  118. </el-select>
  119. </el-form-item>
  120. <el-form-item label="照片" prop="fileList">
  121. <cadUpload v-model="form.fileList" :disabled="false"/>
  122. </el-form-item>
  123. <el-form-item label="备注" prop="remark">
  124. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  125. </el-form-item>
  126. </el-form>
  127. <div slot="footer" class="dialog-footer">
  128. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  129. <el-button @click="cancel">取 消</el-button>
  130. </div>
  131. </el-dialog>
  132. </div>
  133. </template>
  134. <script>
  135. import { listCad, getCad, delCad, addCad, updateCad } from "@/api/gas/cad";
  136. import {listPostAll} from "@/api/system/post";
  137. import cadUpload from "@/components/ImageUpload/cad.vue";
  138. import Cookies from "js-cookie";
  139. export default {
  140. components:{cadUpload},
  141. name: "Cad",
  142. data() {
  143. return {
  144. // 按钮loading
  145. buttonLoading: false,
  146. // 遮罩层
  147. loading: true,
  148. // 导出遮罩层
  149. exportLoading: false,
  150. // 选中数组
  151. ids: [],
  152. // 非单个禁用
  153. single: true,
  154. // 非多个禁用
  155. multiple: true,
  156. // 显示搜索条件
  157. showSearch: true,
  158. // 总条数
  159. total: 0,
  160. // cad图纸表格数据
  161. cadList: [],
  162. // 弹出层标题
  163. title: "",
  164. // 是否显示弹出层
  165. open: false,
  166. // 查询参数
  167. queryParams: {
  168. pageNum: 1,
  169. pageSize: 10,
  170. name: undefined,
  171. postId: (Cookies.get("postName").indexOf('xx') > -1 ? parseInt(Cookies.get("postId")) : undefined),
  172. },
  173. postName:Cookies.get("postName"),
  174. // 表单参数
  175. form: {},
  176. // 表单校验
  177. rules: {
  178. id: [
  179. { required: true, message: "主键不能为空", trigger: "blur" }
  180. ],
  181. name: [
  182. { required: true, message: "名称不能为空", trigger: "blur" }
  183. ],
  184. postId: [
  185. { required: true, message: "队伍id不能为空", trigger: "change" }
  186. ],
  187. },
  188. // 岗位选项
  189. postOptions: [],
  190. };
  191. },
  192. created() {
  193. this.getPostList();
  194. this.getList();
  195. },
  196. methods: {
  197. //获取岗位列
  198. getPostList(){
  199. listPostAll({remark:'ranks'}).then(response => {
  200. this.postOptions = response.data;
  201. });
  202. },
  203. /** 查询cad图纸列表 */
  204. getList() {
  205. this.loading = true;
  206. listCad(this.queryParams).then(response => {
  207. this.cadList = response.rows;
  208. this.total = response.total;
  209. this.loading = false;
  210. });
  211. },
  212. // 取消按钮
  213. cancel() {
  214. this.open = false;
  215. this.reset();
  216. },
  217. // 表单重置
  218. reset() {
  219. this.form = {
  220. id: undefined,
  221. name: undefined,
  222. postId: undefined,
  223. fileList:[],
  224. delFlag: undefined,
  225. createBy: undefined,
  226. createTime: undefined,
  227. updateBy: undefined,
  228. updateTime: undefined,
  229. remark: undefined
  230. };
  231. this.resetForm("form");
  232. },
  233. /** 搜索按钮操作 */
  234. handleQuery() {
  235. this.queryParams.pageNum = 1;
  236. this.getList();
  237. },
  238. /** 重置按钮操作 */
  239. resetQuery() {
  240. this.resetForm("queryForm");
  241. this.handleQuery();
  242. },
  243. // 多选框选中数据
  244. handleSelectionChange(selection) {
  245. this.ids = selection.map(item => item.id)
  246. this.single = selection.length!==1
  247. this.multiple = !selection.length
  248. },
  249. /** 新增按钮操作 */
  250. handleAdd() {
  251. this.reset();
  252. this.open = true;
  253. this.title = "添加cad图纸";
  254. },
  255. /** 修改按钮操作 */
  256. handleUpdate(row) {
  257. this.loading = true;
  258. this.reset();
  259. const id = row.id || this.ids
  260. getCad(id).then(response => {
  261. this.loading = false;
  262. debugger
  263. this.form = response.data;
  264. this.open = true;
  265. this.title = "修改cad图纸";
  266. });
  267. },
  268. /** 提交按钮 */
  269. submitForm() {
  270. console.log(this.from);
  271. this.$refs["form"].validate(valid => {
  272. if (valid) {
  273. this.buttonLoading = true;
  274. if (this.form.id != null) {
  275. updateCad(this.form).then(response => {
  276. this.$modal.msgSuccess("修改成功");
  277. this.open = false;
  278. this.getList();
  279. }).finally(() => {
  280. this.buttonLoading = false;
  281. });
  282. } else {
  283. addCad(this.form).then(response => {
  284. this.$modal.msgSuccess("新增成功");
  285. this.open = false;
  286. this.getList();
  287. }).finally(() => {
  288. this.buttonLoading = false;
  289. });
  290. }
  291. }
  292. });
  293. },
  294. /** 删除按钮操作 */
  295. handleDelete(row) {
  296. const ids = row.id || this.ids;
  297. this.$modal.confirm('是否确认删除cad图纸编号为"' + ids + '"的数据项?').then(() => {
  298. this.loading = true;
  299. return delCad(ids);
  300. }).then(() => {
  301. this.loading = false;
  302. this.getList();
  303. this.$modal.msgSuccess("删除成功");
  304. }).finally(() => {
  305. this.loading = false;
  306. });
  307. },
  308. /** 导出按钮操作 */
  309. handleExport() {
  310. this.$download.excel('/system/cad/export', this.queryParams);
  311. }
  312. }
  313. };
  314. </script>