index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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="userName">
  13. <el-input
  14. v-model="queryParams.userName"
  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="['system:team:add']"
  34. >新增
  35. </el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button
  39. type="success"
  40. plain
  41. icon="el-icon-edit"
  42. size="mini"
  43. :disabled="single"
  44. @click="handleUpdate"
  45. v-hasPermi="['system:team:edit']"
  46. >修改
  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="['system:team:remove']"
  58. >删除
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="warning"
  64. plain
  65. icon="el-icon-download"
  66. size="mini"
  67. @click="handleExport"
  68. v-hasPermi="['system:team:export']"
  69. >导出
  70. </el-button>
  71. </el-col>
  72. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  73. </el-row>
  74. <el-table v-loading="loading" :data="teamList" @selection-change="handleSelectionChange">
  75. <el-table-column type="selection" width="55" align="center"/>
  76. <el-table-column label="主键id" align="center" prop="id"/>
  77. <el-table-column label="姓名" align="center" prop="name"/>
  78. <el-table-column label="账号" align="center" prop="userName"/>
  79. <el-table-column label="组织归属" align="center" prop="dept"/>
  80. <el-table-column label="职务" align="center" prop="post"/>
  81. <el-table-column label="手机号" align="center" prop="phone"/>
  82. <el-table-column label="经度" align="center" prop="longitude"/>
  83. <el-table-column label="纬度" align="center" prop="latitude"/>
  84. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  85. <template slot-scope="scope">
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-edit"
  90. @click="handleUpdate(scope.row)"
  91. v-hasPermi="['system:team:edit']"
  92. >修改
  93. </el-button>
  94. <el-button
  95. size="mini"
  96. type="text"
  97. icon="el-icon-delete"
  98. @click="handleDelete(scope.row)"
  99. v-hasPermi="['system:team:remove']"
  100. >删除
  101. </el-button>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <pagination
  106. v-show="total>0"
  107. :total="total"
  108. :page.sync="queryParams.pageNum"
  109. :limit.sync="queryParams.pageSize"
  110. @pagination="getList"
  111. />
  112. <!-- 添加或修改抢险救援队对话框 -->
  113. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  114. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  115. <el-form-item label="姓名" prop="name">
  116. <el-input v-model="form.name" placeholder="请输入姓名"/>
  117. </el-form-item>
  118. <el-form-item label="账号" prop="userName">
  119. <el-input v-model="form.userName" placeholder="请输入账号"/>
  120. </el-form-item>
  121. <el-form-item label="归属部门" prop="deptId">
  122. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门"/>
  123. </el-form-item>
  124. <el-form-item label="职务" prop="post">
  125. <el-input v-model="form.post" placeholder="请输入职务"/>
  126. </el-form-item>
  127. <el-form-item label="单位" prop="company">
  128. <el-input v-model="form.company" placeholder="请输入单位"/>
  129. </el-form-item>
  130. <el-form-item label="救援队" prop="emergencyRescue">
  131. <el-input v-model="form.emergencyRescue" placeholder="请输入救援队"/>
  132. </el-form-item>
  133. <el-form-item label="手机号" prop="phone">
  134. <el-input v-model="form.phone" placeholder="请输入手机号"/>
  135. </el-form-item>
  136. <el-form-item label="防汛抗旱" prop="effect">
  137. <el-input v-model="form.effect" placeholder="请输入防汛抗旱"/>
  138. </el-form-item>
  139. <el-form-item label="经度" prop="longitude">
  140. <el-input v-model="form.longitude" placeholder="请输入经度"/>
  141. </el-form-item>
  142. <el-form-item label="纬度" prop="latitude">
  143. <el-input v-model="form.latitude" placeholder="请输入纬度"/>
  144. </el-form-item>
  145. </el-form>
  146. <div slot="footer" class="dialog-footer">
  147. <el-button type="primary" @click="submitForm">确 定</el-button>
  148. <el-button @click="cancel">取 消</el-button>
  149. </div>
  150. </el-dialog>
  151. </div>
  152. </template>
  153. <script>
  154. import {addTeam, delTeam, updateTeam,getTeam, listTeam} from "@/api/system/team";
  155. import Treeselect from "@riophae/vue-treeselect";
  156. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  157. import {deptTreeSelect} from "@/api/system/user";
  158. export default {
  159. name: "Team",
  160. components: {Treeselect},
  161. data() {
  162. return {
  163. // 遮罩层
  164. loading: true,
  165. // 选中数组
  166. ids: [],
  167. // 非单个禁用
  168. single: true,
  169. // 非多个禁用
  170. multiple: true,
  171. // 显示搜索条件
  172. showSearch: true,
  173. // 部门树选项
  174. deptOptions: undefined,
  175. // 部门名称
  176. deptName: undefined,
  177. // 总条数
  178. total: 0,
  179. // 抢险救援队表格数据
  180. teamList: [],
  181. // 弹出层标题
  182. title: "",
  183. // 是否显示弹出层
  184. open: false,
  185. // 查询参数
  186. queryParams: {
  187. pageNum: 1,
  188. pageSize: 10,
  189. name: null,
  190. userName: null,
  191. dept: null,
  192. post: null,
  193. company: null,
  194. emergencyRescue: null,
  195. city: null,
  196. area: null,
  197. township: null,
  198. village: null,
  199. phone: null,
  200. effect: null,
  201. longitude: null,
  202. latitude: null
  203. },
  204. // 表单参数
  205. form: {},
  206. // 表单校验
  207. rules: {}
  208. };
  209. },
  210. created() {
  211. this.getList();
  212. this.getDeptTree();
  213. },
  214. methods: {
  215. /** 查询抢险救援队列表 */
  216. getList() {
  217. this.loading = true;
  218. listTeam(this.queryParams).then(response => {
  219. this.teamList = response.rows;
  220. this.total = response.total;
  221. this.loading = false;
  222. });
  223. },
  224. /** 查询部门下拉树结构 */
  225. getDeptTree() {
  226. deptTreeSelect().then(response => {
  227. this.deptOptions = response.data;
  228. });
  229. },
  230. // 取消按钮
  231. cancel() {
  232. this.open = false;
  233. this.reset();
  234. },
  235. // 表单重置
  236. reset() {
  237. this.form = {
  238. id: null,
  239. name: null,
  240. userName: null,
  241. dept: null,
  242. post: null,
  243. company: null,
  244. emergencyRescue: null,
  245. city: null,
  246. area: null,
  247. township: null,
  248. village: null,
  249. phone: null,
  250. effect: null,
  251. longitude: null,
  252. latitude: null
  253. };
  254. this.resetForm("form");
  255. },
  256. /** 搜索按钮操作 */
  257. handleQuery() {
  258. this.queryParams.pageNum = 1;
  259. this.getList();
  260. },
  261. /** 重置按钮操作 */
  262. resetQuery() {
  263. this.resetForm("queryForm");
  264. this.handleQuery();
  265. },
  266. // 多选框选中数据
  267. handleSelectionChange(selection) {
  268. this.ids = selection.map(item => item.id)
  269. this.single = selection.length !== 1
  270. this.multiple = !selection.length
  271. },
  272. /** 新增按钮操作 */
  273. handleAdd() {
  274. this.reset();
  275. this.open = true;
  276. this.title = "添加抢险救援队";
  277. },
  278. /** 修改按钮操作 */
  279. handleUpdate(row) {
  280. this.reset();
  281. const id = row.id || this.ids
  282. getTeam(id).then(response => {
  283. this.form = response.data;
  284. this.open = true;
  285. this.title = "修改抢险救援队";
  286. });
  287. },
  288. /** 提交按钮 */
  289. submitForm() {
  290. this.$refs["form"].validate(valid => {
  291. if (valid) {
  292. if (this.form.id !=null){
  293. updateTeam(this.form).then(response => {
  294. this.$modal.msgSuccess("修改成功");
  295. this.open = false;
  296. this.getList();
  297. });
  298. }else{
  299. addTeam(this.form).then(response => {
  300. this.$modal.msgSuccess("新增成功");
  301. this.open = false;
  302. this.getList();
  303. });
  304. }
  305. }
  306. });
  307. },
  308. /** 删除按钮操作 */
  309. handleDelete(row) {
  310. const ids = row.id || this.ids;
  311. this.$modal.confirm('是否确认删除好差评编号为"' + ids + '"的数据项?').then(function () {
  312. return delTeam(ids);
  313. }).then(() => {
  314. this.getList();
  315. this.$modal.msgSuccess("删除成功");
  316. }).catch(() => {
  317. });
  318. },
  319. /** 导出按钮操作 */
  320. handleExport() {
  321. this.download('system/team/export', {
  322. ...this.queryParams
  323. }, `team_${new Date().getTime()}.xlsx`)
  324. }
  325. }
  326. }
  327. ;
  328. </script>