index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!--
  2. * @Description:
  3. * @Author: gcz
  4. * @Date: 2024-03-04 15:03:37
  5. * @LastEditors: gcz
  6. * @LastEditTime: 2024-03-05 14:18:24
  7. * @FilePath: \great_webui\src\views\device\PDAperson\index.vue
  8. * @Copyright: Copyright (c) 2016~2024 by gcz, All Rights Reserved.
  9. -->
  10. <template>
  11. <div class="app-container">
  12. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  13. <el-form-item label="工号" label-width="40px">
  14. <el-input
  15. v-model="queryParams.jobNum"
  16. placeholder="请输入工号"
  17. clearable
  18. style="width: 140px;"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <!-- <el-form-item label="状态">
  23. <el-select
  24. v-model="queryParams.status"
  25. placeholder="状态"
  26. clearable
  27. style="width: 240px"
  28. >
  29. <el-option
  30. v-for="dict in statusList"
  31. :key="dict.value"
  32. :label="dict.name"
  33. :value="dict.value"
  34. />
  35. </el-select>
  36. </el-form-item> -->
  37. <el-form-item label="姓名">
  38. <el-input
  39. v-model="queryParams.name"
  40. placeholder="请输入姓名"
  41. clearable
  42. style="width: 140px;"
  43. @keyup.enter.native="handleQuery"
  44. />
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  48. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  49. </el-form-item>
  50. </el-form>
  51. <el-row :gutter="10" class="mb8">
  52. <el-col :span="1.5">
  53. <el-button
  54. type="primary"
  55. plain
  56. icon="el-icon-plus"
  57. size="mini"
  58. @click="handleAdd"
  59. v-hasPermi="['device:PDAperson:add']"
  60. >添加</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  63. </el-row>
  64. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  65. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  66. <el-table-column label="工号" align="center" prop="jobNum" />
  67. <el-table-column label="姓名" align="center" prop="name" />
  68. <el-table-column label="联系电话" align="center" prop="mobile" />
  69. <el-table-column label="性别" align="center" prop="sex">
  70. <template slot-scope="scope">
  71. <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="岗位" align="center" prop="postName" />
  75. <el-table-column label="状态" align="center">
  76. <template slot-scope="scope">
  77. <el-tag type="danger" v-if="scope.row.status == '0'">禁用</el-tag>
  78. <el-tag type="success" v-else-if="scope.row.status == '1'">启用</el-tag>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="添加时间" align="center" prop="createTime" width="160">
  82. <template slot-scope="scope">
  83. <span>{{ parseTime(scope.row.createTime) }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
  87. <template slot-scope="scope">
  88. <el-button
  89. size="mini"
  90. type="text"
  91. @click="ionlineApi(scope.row)"
  92. v-hasPermi="['device:PDAperson:edit']"
  93. >{{scope.row.status == '1' ? '禁用' : '启用'}}</el-button>
  94. <el-button
  95. size="mini"
  96. type="text"
  97. @click="handleUpdate(scope.row)"
  98. v-hasPermi="['device:PDAperson:edit']"
  99. >修改</el-button>
  100. <el-button
  101. size="mini"
  102. type="text"
  103. @click="handleDelete(scope.row,scope.index)"
  104. v-hasPermi="['device:PDAperson:delete']"
  105. >删除</el-button>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. @click="resettingApi(scope.row)"
  110. v-hasPermi="['device:PDAperson:edit']"
  111. >重置密码</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. <!-- 新增/编辑弹框 -->
  123. <add-and-edit
  124. ref="addAndEdit"
  125. :dict="dict"
  126. @getList="getList"
  127. />
  128. <el-dialog
  129. title="查看"
  130. :visible.sync="visibleStatus"
  131. width="600px"
  132. :destroy-on-close="true"
  133. :close-on-click-modal="false"
  134. >
  135. <div v-if="visibleType == 'img'">
  136. <el-image
  137. style="width: 400px; height: 100%"
  138. :src="newObj.mainImg"
  139. fit="cover"
  140. />
  141. </div>
  142. <div v-if="visibleType == 'html'">
  143. <div v-html="newObj.centent"></div>
  144. </div>
  145. <div slot="footer" class="dialog-footer">
  146. <el-button type="primary" @click="visibleStatus = false">确 定</el-button>
  147. </div>
  148. </el-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import { pageList, deleteById, ionline,resetPwd } from '@/api/PDAperson/PDAperson'
  153. import addAndEdit from "./dialog/addAndEdit.vue";
  154. export default {
  155. name: "agreement",
  156. dicts: ['sys_user_sex'],
  157. components: { addAndEdit },
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 选中数组
  163. ids: [],
  164. // 非单个禁用
  165. single: true,
  166. // 非多个禁用
  167. multiple: true,
  168. // 显示搜索条件
  169. showSearch: true,
  170. // 总条数
  171. total: 0,
  172. // 用户表格数据
  173. dataList: null,
  174. // 弹出层标题
  175. title: "",
  176. // 是否显示弹出层
  177. open: false,
  178. // 日期范围
  179. dateRange: [],
  180. // 查询参数
  181. queryParams: {
  182. pageNum: 1,
  183. pageSize: 10,
  184. type: undefined
  185. },
  186. statusList: [
  187. {id: 1, name: '未发布', value: 0},
  188. {id: 2, name: '发布', value: 1},
  189. {id: 3, name: '下架', value: 2},
  190. ],
  191. visibleStatus: false,
  192. newObj: {},
  193. visibleType: ''
  194. };
  195. },
  196. created() {
  197. this.getList();
  198. },
  199. methods: {
  200. /** 查询列表 */
  201. getList() {
  202. this.loading = true;
  203. pageList(this.addDateRange(this.queryParams, this.dateRange))
  204. .then(response => {
  205. this.dataList = response.data.rows;
  206. this.total = response.data.total;
  207. this.loading = false;
  208. }
  209. );
  210. },
  211. // 取消按钮
  212. cancel() {
  213. this.open = false;
  214. },
  215. /** 搜索按钮操作 */
  216. handleQuery() {
  217. this.queryParams.pageNum = 1;
  218. this.getList();
  219. },
  220. /** 重置按钮操作 */
  221. resetQuery() {
  222. this.dateRange = [];
  223. this.$set(this.queryParams, 'name', '');
  224. this.$set(this.queryParams, 'status', '');
  225. this.$set(this.queryParams, 'jobNum', '');
  226. this.queryParams.pageNum = 1;
  227. this.handleQuery();
  228. },
  229. // 多选框选中数据
  230. handleSelectionChange(selection) {
  231. this.ids = selection.map(item => item.userId);
  232. this.single = selection.length != 1;
  233. this.multiple = !selection.length;
  234. },
  235. /** 新增按钮操作 */
  236. handleAdd() {
  237. this.$refs["addAndEdit"].openDialog("新增数据", null);
  238. },
  239. /** 修改按钮操作 */
  240. handleUpdate(row) {
  241. this.$refs["addAndEdit"].openDialog("修改数据", row);
  242. },
  243. /** 发布或者取消发布按钮操作 */
  244. ionlineApi(row) {
  245. this.$confirm("是否对" + row.name + (row.status == 1 ? '禁用?' : '启用?'), '提示', {
  246. confirmButtonText: '确定',
  247. cancelButtonText: '取消',
  248. type: 'warning'
  249. }).then(() => {
  250. ionline({ userId: row.id, status: row.status == 1 ? 0 : 1 }).then((res) => {
  251. if (res.code == 200) {
  252. this.$message({
  253. type: 'success',
  254. message: '操作成功!'
  255. });
  256. this.getList();
  257. }
  258. });
  259. }).catch(() => {});
  260. },
  261. /** 重置密码按钮操作 */
  262. resettingApi(row) {
  263. this.$confirm("是否对" + row.name + "的数据进行密码重置?重置后的密码为123456!", '提示', {
  264. confirmButtonText: '确定',
  265. cancelButtonText: '取消',
  266. type: 'warning'
  267. }).then(() => {
  268. resetPwd({ userId: row.id, newPassword: '123456' }).then((res) => {
  269. if (res.code == 200) {
  270. this.$message({
  271. type: 'success',
  272. message: '操作成功!'
  273. });
  274. this.getList();
  275. }
  276. });
  277. }).catch(() => {});
  278. },
  279. /** 删除按钮操作 */
  280. handleDelete(row) {
  281. this.$modal.confirm('是否确认删除"' + row.name + '"的数据项?').then(function() {
  282. return deleteById(row.id);
  283. }).then(() => {
  284. this.getList();
  285. this.$modal.msgSuccess("删除成功");
  286. }).catch(() => {});
  287. },
  288. /** 查看按钮操作 */
  289. seeCenter(obj, type) {
  290. this.visibleStatus = true
  291. this.visibleType = type;
  292. this.newObj = obj;
  293. }
  294. }
  295. };
  296. </script>