index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template slot="header" slot-scope="scope">
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item style="float:right;">
  5. <!-- <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> -->
  6. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">添加</el-button>
  7. </el-form-item>
  8. </el-form>
  9. <el-table v-loading="loading" :data="personnelList" @selection-change="handleSelectionChange">
  10. <el-table-column label="油站员工主键id" v-if="false" align="center" prop="personnelId" />
  11. <el-table-column label="员工姓名" align="center" prop="personnelName" />
  12. <el-table-column label="负责枪号" align="center" prop="gunNo" />
  13. <el-table-column label="加油站id" v-if="false" align="center" prop="stationId" />
  14. <el-table-column label="加油站名称" align="center" prop="stationName" />
  15. <!-- <el-table-column label="二维码" align="center" prop="qrCode" /> -->
  16. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  17. <template slot-scope="scope">
  18. <!-- <el-button
  19. size="mini"
  20. type="text"
  21. icon="el-icon-plus"
  22. >微信绑定</el-button> -->
  23. <el-button
  24. size="mini"
  25. type="text"
  26. icon="el-icon-edit"
  27. @click="handleUpdate(scope.row)"
  28. v-hasPermi="['station:personnel:edit']"
  29. >修改</el-button>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. <pagination
  34. v-show="total>0"
  35. :total="total"
  36. :page.sync="queryParams.pageNum"
  37. :limit.sync="queryParams.pageSize"
  38. @pagination="getList"
  39. />
  40. <!-- 添加或修改油站员工信息对话框 -->
  41. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  42. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  43. <el-form-item label="姓名" prop="personnelName">
  44. <el-input v-model="form.personnelName" placeholder="请输入员工姓名" />
  45. </el-form-item>
  46. <el-form-item label="负责枪号" prop="gunNo">
  47. <el-checkbox-group v-model="gunNoList">
  48. <el-checkbox
  49. v-for = "item in checkList"
  50. :key=item.oilGunId
  51. :label="item.oilGunNo"
  52. :value="item.oilGunNo"
  53. >
  54. {{item.oilGunNo+"号枪/"+item.oilName}}
  55. </el-checkbox>
  56. </el-checkbox-group>
  57. </el-form-item>
  58. <el-form-item label="手机号" prop="personnelPhone">
  59. <el-input v-model="form.personnelPhone" placeholder="请输入员工手机号" />
  60. </el-form-item>
  61. </el-form>
  62. <div slot="footer" class="dialog-footer">
  63. <el-button type="primary" @click="submitForm">确 定</el-button>
  64. <el-button @click="cancel">取 消</el-button>
  65. </div>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import { listPersonnel, getPersonnel, delPersonnel, addPersonnel, updatePersonnel, exportPersonnel } from "@/api/station/personnel";
  71. import {stationinfo,listGun} from "@/api/station/gun";
  72. import { getDept } from "@/api/system/dept";
  73. export default {
  74. name: "Personnel",
  75. data() {
  76. return {
  77. // 遮罩层
  78. loading: true,
  79. // 选中数组
  80. ids: [],
  81. // 非单个禁用
  82. single: true,
  83. // 非多个禁用
  84. multiple: true,
  85. // 显示搜索条件
  86. showSearch: true,
  87. // 总条数
  88. total: 0,
  89. // 油站员工信息表格数据
  90. personnelList: [],
  91. stationOptions:[],
  92. checkList:[],
  93. gunNoList:[],
  94. // 弹出层标题
  95. title: "",
  96. // 是否显示弹出层
  97. open: false,
  98. // 查询参数
  99. queryParams: {
  100. pageNum: 1,
  101. pageSize: 10,
  102. personnelName: null,
  103. gunNo: null,
  104. stationId: null,
  105. stationName: null,
  106. qrCode: null,
  107. personnelPhone: null
  108. },
  109. // 查询参数
  110. queryInfo: {
  111. stationId: null
  112. },
  113. query:{
  114. deptId: null
  115. },
  116. // 表单参数
  117. form: {},
  118. // 表单校验
  119. rules: {
  120. }
  121. };
  122. },
  123. created() {
  124. this.getList();
  125. this.query.deptId =this.$store.selectDeptId;
  126. if(this.query.deptId ==null || this.query.deptId ==""){
  127. this.query.deptId =this.$store.state.user.deptId;
  128. }
  129. stationinfo(this.query).then(response => {
  130. this.stationOptions = response.rows;
  131. });
  132. },
  133. methods: {
  134. /** 查询油站员工信息列表 */
  135. getList() {
  136. this.loading = true;
  137. this.queryParams.stationId=this.$store.selectDeptId;
  138. if(this.queryParams.stationId==null || this.queryParams.stationId==""){
  139. this.queryParams.stationId =this.$store.state.user.deptId;
  140. }
  141. listPersonnel(this.queryParams).then(response => {
  142. this.queryParams.stationId=null;
  143. this.personnelList = response.rows;
  144. this.total = response.total;
  145. this.loading = false;
  146. });
  147. },
  148. onInstitutionChang(e){
  149. let obj = {};
  150. obj = this.stationOptions.find((item)=>{//这里的userList就是上面遍历的数据源
  151. return item.deptId === e;//筛选出匹配数据
  152. })
  153. this.form.stationName=obj.deptName;
  154. this.queryInfo.stationId=obj.deptId;
  155. listGun(this.queryInfo).then(response => {
  156. this.checkList = response.rows;
  157. });
  158. },
  159. // 取消按钮
  160. cancel() {
  161. this.open = false;
  162. this.reset();
  163. },
  164. // 表单重置
  165. reset() {
  166. this.form = {
  167. personnelId: null,
  168. personnelName: null,
  169. gunNo: null,
  170. stationId: null,
  171. stationName: null,
  172. qrCode: null,
  173. personnelPhone: null
  174. };
  175. this.resetForm("form");
  176. this.gunNoList.length=0;
  177. },
  178. /** 搜索按钮操作 */
  179. handleQuery() {
  180. this.queryParams.pageNum = 1;
  181. this.getList();
  182. },
  183. /** 重置按钮操作 */
  184. resetQuery() {
  185. this.resetForm("queryForm");
  186. this.handleQuery();
  187. },
  188. // 多选框选中数据
  189. handleSelectionChange(selection) {
  190. this.ids = selection.map(item => item.personnelId)
  191. this.single = selection.length!==1
  192. this.multiple = !selection.length
  193. },
  194. /** 新增按钮操作 */
  195. handleAdd() {
  196. this.reset();
  197. this.deptId=this.$store.selectDeptId;
  198. if(this.deptId==null || this.deptId==""){
  199. this.deptId =this.$store.state.user.deptId;
  200. }
  201. getDept(this.deptId).then(response => {
  202. this.deptInfo = response.data;
  203. if(this.deptInfo.jiBie==2){
  204. this.open = true;
  205. this.title = "添加油站员工信息";
  206. this.form.stationId=this.deptInfo.deptId;
  207. this.form.stationName=this.deptInfo.deptName;
  208. this.queryInfo.stationId=this.deptInfo.deptId;
  209. listGun(this.queryInfo).then(response => {
  210. this.checkList = response.rows;
  211. });
  212. }else{
  213. this.msgSuccess("请选择油站");
  214. }
  215. });
  216. },
  217. /** 修改按钮操作 */
  218. handleUpdate(row) {
  219. this.reset();
  220. const personnelId = row.personnelId || this.ids
  221. getPersonnel(personnelId).then(response => {
  222. this.form = response.data;
  223. if(this.form.gunNo!=null &&this.form.gunNo!="" ){
  224. this.gunNoList=this.form.gunNo.split(",");
  225. }
  226. this.queryInfo.stationId=row.stationId;
  227. listGun(this.queryInfo).then(response => {
  228. this.checkList = response.rows;
  229. });
  230. this.open = true;
  231. this.title = "修改油站员工信息";
  232. });
  233. },
  234. /** 提交按钮 */
  235. submitForm() {
  236. this.$refs["form"].validate(valid => {
  237. if (valid) {
  238. if(this.gunNoList !=null && this.gunNoList.length>0){
  239. //判断
  240. let list=[];
  241. for(let i=0;i<this.gunNoList.length;i++){
  242. for(let j=0;j<this.checkList.length;j++){
  243. if(this.gunNoList[i]==this.checkList[j].oilGunNo){
  244. list.push(this.checkList[j].oilGunNo);
  245. }
  246. }
  247. }
  248. this.form.gunNo=list.toString();
  249. }
  250. if (this.form.personnelId != null) {
  251. updatePersonnel(this.form).then(response => {
  252. this.msgSuccess("修改成功");
  253. this.open = false;
  254. this.getList();
  255. });
  256. } else {
  257. addPersonnel(this.form).then(response => {
  258. this.msgSuccess("新增成功");
  259. this.open = false;
  260. this.getList();
  261. });
  262. }
  263. }
  264. });
  265. },
  266. /** 删除按钮操作 */
  267. handleDelete(row) {
  268. const personnelIds = row.personnelId || this.ids;
  269. this.$confirm('是否确认删除油站员工信息', "警告", {
  270. confirmButtonText: "确定",
  271. cancelButtonText: "取消",
  272. type: "warning"
  273. }).then(function() {
  274. return delPersonnel(personnelIds);
  275. }).then(() => {
  276. this.getList();
  277. this.msgSuccess("删除成功");
  278. })
  279. },
  280. /** 导出按钮操作 */
  281. handleExport() {
  282. const queryParams = this.queryParams;
  283. this.$confirm('是否确认导出所有油站员工信息数据项?', "警告", {
  284. confirmButtonText: "确定",
  285. cancelButtonText: "取消",
  286. type: "warning"
  287. }).then(function() {
  288. return exportPersonnel(queryParams);
  289. }).then(response => {
  290. this.download(response.msg);
  291. })
  292. }
  293. }
  294. };
  295. </script>