plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1238 lines
39 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="mod-user">
  3. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  4. <el-form-item>
  5. <el-input v-model="dataForm.userName" placeholder="用户账号" clearable></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button @click="getDataList()" type="primary">{{ buttons.search || '查询' }}</el-button>
  9. <el-button v-if="isAuth('sys:user:save')" type="primary" @click="addOrUpdateHandle()">
  10. {{ buttons.add || '新增' }}
  11. </el-button>
  12. <el-button v-if="isAuth('sys:user:save')" :disabled="this.showButton" type="primary"
  13. @click="specialAuthorize()"
  14. >{{ buttons.specialCompetencies || '特殊权限' }}
  15. </el-button>
  16. <el-button v-if="isAuth('sys:user:save')" :disabled="this.showButton" type="primary"
  17. @click="siteAuthorize()"
  18. > {{ buttons.factoryAuthorization || '工厂授权' }}
  19. </el-button>
  20. <el-button v-if="isAuth('sys:user:save')" :disabled="this.showButton" type="primary"
  21. @click="buAuthorize()"
  22. > {{ buttons.buAuthorization || 'BU授权' }}
  23. </el-button>
  24. <el-button v-if="isAuth('sys:user:save')" :disabled="this.showButton" type="primary"
  25. @click="projectModel()"
  26. > {{ buttons.projectAuthorization || '项目授权' }}
  27. </el-button>
  28. <el-button v-if="isAuth('sys:user:save')" :disabled="this.showButton" type="primary"
  29. @click="FieldListModel()"
  30. > {{ buttons.fieldAuthorization || '字段授权' }}
  31. </el-button>
  32. </el-form-item>
  33. </el-form>
  34. <el-table
  35. :data="dataList"
  36. border
  37. :height="height"
  38. v-loading="dataListLoading"
  39. @selection-change="selectionChangeHandle"
  40. highlight-current-row
  41. @current-change="handleCurrentChange"
  42. style="width: 100%;">
  43. <el-table-column
  44. prop="username"
  45. header-align="center"
  46. align="center"
  47. :label="buttons.username||'用户账号'">
  48. </el-table-column>
  49. <el-table-column
  50. prop="userDisplay"
  51. header-align="center"
  52. align="center"
  53. :label="buttons.userDisplay||'用户名'">
  54. </el-table-column>
  55. <el-table-column
  56. prop="buDesc"
  57. header-align="center"
  58. align="center"
  59. :label="'BU'">
  60. </el-table-column>
  61. <el-table-column
  62. prop="departmentName"
  63. header-align="center"
  64. align="center"
  65. :label="'部门'">
  66. </el-table-column>
  67. <el-table-column
  68. prop="postName"
  69. header-align="center"
  70. align="center"
  71. :label="'岗位'">
  72. </el-table-column>
  73. <el-table-column
  74. prop="email"
  75. header-align="center"
  76. align="center"
  77. :label="buttons.email||'邮箱'">
  78. </el-table-column>
  79. <el-table-column
  80. prop="mobile"
  81. header-align="center"
  82. align="center"
  83. :label="buttons.mobile||'手机号'">
  84. </el-table-column>
  85. <el-table-column
  86. prop="status"
  87. header-align="center"
  88. align="center"
  89. :label="buttons.status||'状态'">
  90. <template slot-scope="scope">
  91. <el-link v-if="scope.row.status === 0" type="success">{{ buttons.disable || '禁用' }}</el-link>
  92. <el-link v-else type="danger">{{ buttons.normal || '正常' }}</el-link>
  93. </template>
  94. </el-table-column>
  95. <el-table-column
  96. prop="createTime"
  97. header-align="center"
  98. align="center"
  99. width="180"
  100. :label="buttons.createTime||'创建时间'">
  101. </el-table-column>
  102. <el-table-column
  103. fixed="right"
  104. header-align="center"
  105. align="center"
  106. width="150"
  107. :label="buttons.cz||'操作'">
  108. <template slot-scope="scope">
  109. <!-- <a type="text" size="small" @click="generateData(scope.row)">{{ buttons.auth || '审核' }}</a>-->
  110. <a type="text" size="small" @click="permissionList(scope.row)">权限清单</a>
  111. <a v-if="isAuth('sys:user:update')" type="text" size="small"
  112. @click="addOrUpdateHandle(scope.row.userId)">{{ buttons.edit || '修改' }}</a>
  113. <a v-if="isAuth('sys:user:delete')" type="text" size="small"
  114. @click="deleteHandle(scope.row.userId)">{{ buttons.delete || '删除' }}</a>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <el-pagination
  119. @size-change="sizeChangeHandle"
  120. @current-change="currentChangeHandle"
  121. :current-page="pageIndex"
  122. :page-sizes="[20, 50, 100, 200, 500]"
  123. :page-size="pageSize"
  124. :total="totalPage"
  125. layout="total, sizes, prev, pager, next, jumper">
  126. </el-pagination>
  127. <!-- 权限清单 -->
  128. <el-dialog title="权限清单" @close="closeDataDialog" @open="getUserAccessSiteInfoList" :close-on-click-modal="false" v-drag :visible.sync="permissionFlag" width="900px">
  129. <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
  130. 用户 <el-input v-model="selectUser.username" style="width: 130px" readonly></el-input>
  131. 名称 <el-input v-model="selectUser.userDisplay" style="width: 130px" readonly></el-input>
  132. <el-tabs v-model="activeTable" style="margin-top: 0; width: 100%; min-height: 350px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border: 2px;" @tab-click="tabClick" class="customer-tab">
  133. <!-- 工厂权限页签 -->
  134. <el-tab-pane label="工厂权限" name="factory_information" style="height: 350px;">
  135. <el-table
  136. :data="userSiteList"
  137. border
  138. style="width: 100%;height: 500px">
  139. <el-table-column
  140. prop="siteID"
  141. header-align="center"
  142. align="center"
  143. min-width="50"
  144. label="工厂编码">
  145. </el-table-column>
  146. <el-table-column
  147. prop="siteName"
  148. header-align="center"
  149. align="center"
  150. min-width="100"
  151. label="工厂名称">
  152. </el-table-column>
  153. <el-table-column
  154. prop="address"
  155. header-align="center"
  156. align="center"
  157. min-width="100"
  158. label="地址">
  159. </el-table-column>
  160. </el-table>
  161. </el-tab-pane>
  162. <!-- BU权限页签 -->
  163. <el-tab-pane label="BU权限" name="BU_information" style="height: 350px;">
  164. <el-table
  165. :data="userBUList"
  166. border
  167. style="width: 100%;height: 500px">
  168. <el-table-column
  169. prop="site"
  170. header-align="center"
  171. align="center"
  172. min-width="50"
  173. label="工厂编码">
  174. </el-table-column>
  175. <el-table-column
  176. prop="buNo"
  177. header-align="center"
  178. align="center"
  179. min-width="100"
  180. label="部门编码">
  181. </el-table-column>
  182. <el-table-column
  183. prop="buDesc"
  184. header-align="center"
  185. align="center"
  186. min-width="100"
  187. label="部门名称">
  188. </el-table-column>
  189. </el-table>
  190. </el-tab-pane>
  191. <!-- 项目权限页签 -->
  192. <el-tab-pane label="项目权限" name="project_information" style="height: 350px;">
  193. <el-table
  194. :data="userProjectList"
  195. border
  196. style="width: 100%;height: 500px">
  197. <el-table-column
  198. prop="site"
  199. header-align="center"
  200. align="center"
  201. min-width="50"
  202. label="工厂编码">
  203. </el-table-column>
  204. <el-table-column
  205. prop="buDesc"
  206. header-align="center"
  207. align="center"
  208. min-width="100"
  209. label="部门名称">
  210. </el-table-column>
  211. <el-table-column
  212. prop="projectId"
  213. header-align="center"
  214. align="center"
  215. min-width="50"
  216. label="项目号">
  217. </el-table-column>
  218. <el-table-column
  219. prop="status"
  220. header-align="center"
  221. align="center"
  222. min-width="100"
  223. label="项目状态">
  224. </el-table-column>
  225. <el-table-column
  226. prop="needDate"
  227. header-align="center"
  228. align="center"
  229. min-width="100"
  230. label="要求完成时间">
  231. </el-table-column>
  232. </el-table>
  233. </el-tab-pane>
  234. <!-- 字段权限页签 -->
  235. <el-tab-pane label="字段权限" name="field_function_information" style="height: 350px;">
  236. <el-table
  237. :data="userFieldList"
  238. border
  239. style="width: 100%;height: 500px">
  240. <el-table-column
  241. prop="functionName"
  242. header-align="center"
  243. align="center"
  244. min-width="50"
  245. label="功能名称">
  246. </el-table-column>
  247. <el-table-column
  248. prop="functionGroup"
  249. header-align="center"
  250. align="center"
  251. min-width="100"
  252. label="功能分组">
  253. </el-table-column>
  254. <el-table-column
  255. prop="fieldDesc"
  256. header-align="center"
  257. align="center"
  258. min-width="50"
  259. label="字段名称">
  260. </el-table-column>
  261. </el-table>
  262. </el-tab-pane>
  263. <!-- 特殊权限页签 -->
  264. <el-tab-pane label="特殊权限" name="security_information" style="height: 350px;">
  265. <el-table
  266. :data="securityList"
  267. border
  268. v-loading="dataListLoading"
  269. style="width: 100%;height: 500px">
  270. <el-table-column
  271. v-for="(item,index) in columnList" :key="index"
  272. :sortable="item.columnSortable"
  273. :prop="item.columnProp"
  274. :header-align="item.headerAlign"
  275. :show-overflow-tooltip="item.showOverflowTooltip"
  276. :align="item.align"
  277. :fixed="item.fixed==''?false:item.fixed"
  278. :min-width="item.columnWidth"
  279. :label="item.columnLabel">
  280. <template slot-scope="scope">
  281. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  282. <span v-if="item.columnHidden">
  283. <el-checkbox v-model="scope.row[item.columnProp] "></el-checkbox>
  284. </span>
  285. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  286. style="width: 100px; height: 80px"/></span>
  287. </template>
  288. </el-table-column>
  289. </el-table>
  290. </el-tab-pane>
  291. </el-tabs>
  292. </el-form>
  293. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  294. <el-button @click="permissionFlag = false" type="primary">关闭</el-button>
  295. </el-footer>
  296. </el-dialog>
  297. <!-- 弹窗, 新增 / 修改 -->
  298. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  299. <!-- 审核权限 -->
  300. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" v-drag :title="inputSearch1"
  301. :visible.sync="setUp.reviewFlag" width="518px">
  302. <template>
  303. <el-transfer v-model="checked" :data="transferData"
  304. :titles="[buttons.allAuth || '所有权限', buttons.currentAuth || '当前权限']"></el-transfer>
  305. </template>
  306. <span slot="footer" class="dialog-footer">
  307. <div style="margin-top: 5px">
  308. <el-button type="primary" :disabled="setUp.saveButton" @click="saveUserRoleFlag()">确定</el-button>
  309. <el-button type="primary" @click="setUp.reviewFlag = false">取消</el-button>
  310. </div>
  311. </span>
  312. </el-dialog>
  313. <!-- 特殊权限 -->
  314. <el-dialog
  315. v-drag
  316. :title="'特殊性权限'"
  317. :visible.sync="specialVisible"
  318. width="820px"
  319. :append-to-body="true">
  320. <el-table
  321. :data="securityList"
  322. border
  323. :height="securityHeight"
  324. v-loading="dataListLoading"
  325. style="width: 100%;">
  326. <el-table-column
  327. v-for="(item,index) in columnList" :key="index"
  328. :sortable="item.columnSortable"
  329. :prop="item.columnProp"
  330. :header-align="item.headerAlign"
  331. :show-overflow-tooltip="item.showOverflowTooltip"
  332. :align="item.align"
  333. :fixed="item.fixed==''?false:item.fixed"
  334. :min-width="item.columnWidth"
  335. :label="item.columnLabel">
  336. <template slot-scope="scope">
  337. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  338. <span v-if="item.columnHidden">
  339. <el-checkbox v-model="scope.row[item.columnProp] "></el-checkbox>
  340. </span>
  341. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  342. style="width: 100px; height: 80px"/></span>
  343. </template>
  344. </el-table-column>
  345. </el-table>
  346. <span slot="footer" class="dialog-footer">
  347. <el-button type="primary" @click="saveUserSecurity()">确定</el-button>
  348. <el-button @click="specialVisible = false" type="primary">取消</el-button>
  349. </span>
  350. </el-dialog>
  351. <!-- 工厂授权 -->
  352. <el-dialog
  353. style="font-size: 12px"
  354. v-drag
  355. :title="'工厂授权'"
  356. :visible.sync="siteVisible"
  357. width="518px"
  358. :append-to-body="true"
  359. @close="closeDataDialog">
  360. <el-transfer class="rq" filterable v-model="selectSitList" :data="siteList" :titles="['未授权工厂', '已授权工厂']"></el-transfer>
  361. <span slot="footer" class="dialog-footer">
  362. <div style="margin-top: 5px">
  363. <el-button type="primary" @click="saveUserAssessSite()">确定</el-button>
  364. <el-button @click="siteVisible = false" type="primary">取消</el-button>
  365. </div>
  366. </span>
  367. </el-dialog>
  368. <!-- BU授权 -->
  369. <el-dialog
  370. style="font-size: 12px"
  371. v-drag
  372. :title="'BU授权'"
  373. :visible.sync="buVisible"
  374. width="518px"
  375. :append-to-body="true">
  376. <el-transfer class="rq" filterable v-model="selectBUList" :props="{
  377. key: 'buNo',
  378. label: 'buDesc'
  379. }" :data="buList" :titles="['未授权BU', '已授权BU']"></el-transfer>
  380. <span slot="footer" class="dialog-footer">
  381. <div style="margin-top: 5px">
  382. <el-button type="primary" @click="saveBuAssessSite()">确定</el-button>
  383. <el-button @click="buVisible = false" type="primary">取消</el-button>
  384. </div>
  385. </span>
  386. </el-dialog>
  387. <!-- 功能清单 -->
  388. <el-dialog
  389. width="600px"
  390. title="功能清单"
  391. :close-on-click-modal="false"
  392. :visible.sync="functionFlag">
  393. <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
  394. 用户 <el-input v-model="selectUser.username" style="width: 130px" readonly></el-input>
  395. 名称 <el-input v-model="selectUser.userDisplay" style="width: 130px" readonly></el-input>
  396. </el-form>
  397. <el-table
  398. height="300"
  399. :data="functionList"
  400. border
  401. style="width: 100%">
  402. <el-table-column
  403. prop="functionName"
  404. header-align="center"
  405. align="left"
  406. min-width="80"
  407. label="功能名称">
  408. </el-table-column>
  409. <el-table-column
  410. prop="functionGroup"
  411. header-align="center"
  412. align="left"
  413. min-width="100"
  414. label="功能分组">
  415. </el-table-column>
  416. <el-table-column
  417. prop=""
  418. header-align="center"
  419. align="center"
  420. width="60"
  421. label="操作">
  422. <template slot-scope="scope" class="foo_container">
  423. <a type="text" size="small" @click="accessModel(scope.row)">授权</a>
  424. </template>
  425. </el-table-column>
  426. </el-table>
  427. <span slot="footer" class="dialog-footer">
  428. <el-button type="primary" @click="functionFlag = false">关闭</el-button>
  429. </span>
  430. </el-dialog>
  431. <!-- 字段授权 -->
  432. <el-dialog
  433. style="font-size: 12px"
  434. v-drag
  435. :title="'字段授权'"
  436. :visible.sync="fieldFlag"
  437. width="518px"
  438. :append-to-body="true">
  439. <el-transfer v-model="selectFieldList" class="rq" filterable :props="{
  440. key: 'fieldId',
  441. label: 'fieldDesc'
  442. }" :data="fieldList" :titles="['未选择', '已选择']"></el-transfer>
  443. <span slot="footer" class="dialog-footer">
  444. <div style="margin-top: 5px">
  445. <el-button type="primary" @click="saveAccessFieldListByUser()">确定</el-button>
  446. <el-button @click="fieldFlag = false" type="primary">取消</el-button>
  447. </div>
  448. </span>
  449. </el-dialog>
  450. <el-dialog
  451. width="600px"
  452. title="项目权限"
  453. :close-on-click-modal="false"
  454. :visible.sync="projectRoleFlag">
  455. <el-table
  456. :data="projectRoleList"
  457. border
  458. :height="400"
  459. v-loading="false"
  460. style="width: 100%;">
  461. <el-table-column
  462. prop="projectId"
  463. header-align="center"
  464. align="center"
  465. min-width="50"
  466. label="项目号">
  467. </el-table-column>
  468. <el-table-column
  469. prop="projectDesc"
  470. header-align="center"
  471. align="center"
  472. min-width="100"
  473. label="项目描述">
  474. </el-table-column>
  475. <el-table-column
  476. prop=""
  477. header-align="center"
  478. align="center"
  479. min-width="25"
  480. label="">
  481. <template slot-scope="scope">
  482. <!-- 如果数据为Y显示勾选框否则不勾选 -->
  483. <el-checkbox v-model="scope.row.checkAll" @change="changeAll(scope.row)"></el-checkbox>
  484. </template>
  485. </el-table-column>
  486. <el-table-column
  487. prop=""
  488. header-align="center"
  489. align="center"
  490. min-width="25"
  491. label="查询">
  492. <template slot-scope="scope">
  493. <!-- 如果数据为Y显示勾选框否则不勾选 -->
  494. <el-checkbox v-model="scope.row.searchCheck" @change="changeCheck(scope.row,1)"></el-checkbox>
  495. </template>
  496. </el-table-column>
  497. <el-table-column
  498. prop=""
  499. header-align="center"
  500. align="center"
  501. min-width="25"
  502. label="修改">
  503. <template slot-scope="scope">
  504. <!-- 如果数据为Y显示勾选框否则不勾选 -->
  505. <el-checkbox v-model="scope.row.updateCheck" @change="changeCheck(scope.row,2)"></el-checkbox>
  506. </template>
  507. </el-table-column>
  508. <el-table-column
  509. prop=""
  510. header-align="center"
  511. align="center"
  512. min-width="25"
  513. label="下载">
  514. <template slot-scope="scope">
  515. <!-- 如果数据为Y显示勾选框否则不勾选 -->
  516. <el-checkbox v-model="scope.row.downCheck" @change="changeCheck(scope.row,3)"></el-checkbox>
  517. </template>
  518. </el-table-column>
  519. <el-table-column
  520. prop=""
  521. header-align="center"
  522. align="center"
  523. min-width="25"
  524. label="删除">
  525. <template slot-scope="scope">
  526. <!-- 如果数据为Y显示勾选框否则不勾选 -->
  527. <el-checkbox v-model="scope.row.deleteCheck" @change="changeCheck(scope.row,4)"></el-checkbox>
  528. </template>
  529. </el-table-column>
  530. </el-table>
  531. <span slot="footer" class="dialog-footer">
  532. <div style="margin-top: 5px">
  533. <el-button type="primary" @click="saveAccessProject()">确定</el-button>
  534. <el-button @click="projectRoleFlag = false" type="primary">取消</el-button>
  535. </div>
  536. </span>
  537. </el-dialog>
  538. </div>
  539. </template>
  540. <script>
  541. import {getUserAccessSiteList, saveUserAccessSiteList} from '@/api/factory/accessSite.js'
  542. import {getSiteList} from '@/api/factory/site.js'
  543. import {searchAccessBuList,saveAccessBU,searchAccessProjectForUser,saveAccessProject, getUserAccessSiteInfoList, getUserAccessBUInfoList, getUserAccessProjectInfoList} from '@/api/base/site.js'
  544. import {
  545. searchFieldFunctionList,searchAccessFieldListByUser,saveAccessFieldListByUser,getUserAccessFieldFunctionInfoList
  546. } from "@/api/base/field.js"
  547. import AddOrUpdate from './user-add-or-update'
  548. import {getUserBusinessRoleList, saveUserBusinessRole} from '@/api/auditManagement/auditType.js'
  549. import {
  550. getUserSpecialSecurity,
  551. saveUserSpecialSecurity,
  552. updateUserSpecialSecurity,
  553. } from '@/api/factory/userSpecialSecurity.js'
  554. import {debounce, throttle} from "../../../utils/common";
  555. import {
  556. searchFunctionButtonList,
  557. } from "@/api/sysLanguage.js"
  558. import {
  559. getBUList,
  560. getDepartmentList,
  561. getPostList,
  562. saveAccessSiteForSite,
  563. searchAccessSiteListBySite
  564. } from '../../../api/base/site'
  565. export default {
  566. data() {
  567. return {
  568. accessSiteVisible: false,
  569. projectRoleFlag: false,
  570. projectRoleList: [],
  571. accessSiteList: [],
  572. showButton: true,
  573. height: 200,
  574. securityHeight: 300,
  575. specialVisible: false,
  576. siteVisible: false,
  577. buVisible: false,
  578. currentData: {},
  579. userId: this.$store.state.user.name,
  580. transferData: [],
  581. checked: [],
  582. selectBUList: [],
  583. buList: [],
  584. userSiteList: [],
  585. userBUList:[],
  586. userProjectList:[],
  587. userFieldList:[],
  588. userData: [],
  589. inputSearch1: '审核权限',
  590. //设置
  591. setUp: {
  592. reviewFlag: false,
  593. saveButton: false,
  594. },
  595. dataForm: {
  596. id: 0,
  597. userName: '',
  598. password: '',
  599. comfirmPassword: '',
  600. languageDefault: '',
  601. salt: '',
  602. email: '',
  603. mobile: '',
  604. buNo: '',
  605. buDesc: '',
  606. departmentNo:'',
  607. departmentName:'',
  608. postNo:'',
  609. postName:'',
  610. roleIdList: [],
  611. status: 1,
  612. site: '',
  613. siteID: '',
  614. siteName:'',
  615. userDisplay: ''
  616. },
  617. // 初始页签
  618. activeTable: 'factory_information',
  619. columnList: [
  620. {
  621. userId: this.$store.state.user.name,
  622. serialNumber: 'security' + this.$route.meta.menuId + 'securitydesc',
  623. tableId: this.$route.meta.menuId + 'security',
  624. tableName: "securityTable",
  625. columnProp: "securitydesc",
  626. headerAlign: "center",
  627. align: "left",
  628. columnLabel: "参数描述",
  629. columnHidden: false,
  630. columnImage: false,
  631. columnWidth: 70,
  632. columnSortable: false,
  633. sortLv: 0,
  634. status: true,
  635. fixed: '',
  636. },
  637. {
  638. userId: this.$store.state.user.name,
  639. serialNumber: 'security' + this.$route.meta.menuId + 'securitydesc',
  640. tableId: this.$route.meta.menuId + 'security',
  641. tableName: "securityTable",
  642. columnProp: "module",
  643. headerAlign: "center",
  644. align: "left",
  645. columnLabel: "模块",
  646. columnHidden: false,
  647. columnImage: false,
  648. columnSortable: false,
  649. columnWidth: 20,
  650. sortLv: 0,
  651. status: true,
  652. fixed: '',
  653. },
  654. {
  655. userId: this.$store.state.user.name,
  656. serialNumber: 'security' + this.$route.meta.menuId + 'securitydesc',
  657. tableId: this.$route.meta.menuId + 'security',
  658. tableName: "securityTable",
  659. columnProp: "itemvalue",
  660. headerAlign: "center",
  661. align: "center",
  662. columnLabel: "参数值",
  663. columnHidden: true,
  664. columnImage: false,
  665. columnSortable: false,
  666. columnWidth: 10,
  667. sortLv: 0,
  668. status: true,
  669. fixed: '',
  670. },
  671. ],
  672. buttons: {
  673. cz: '操作',
  674. search: '查询',
  675. add: '添加',
  676. permissionList: '权限清单',
  677. edit: '编辑',
  678. delete: '删除',
  679. specialCompetencies: '特殊权限',
  680. factoryAuthorization: '工厂授权',
  681. buAuthorization: 'BU授权',
  682. projectAuthorization: '项目授权',
  683. createTime: '创建时间',
  684. username: '用户账号',
  685. userDisplay: '用户名',
  686. email: '邮箱',
  687. mobile: '手机号',
  688. status: '状态',
  689. disable: '禁用',
  690. normal: '正常',
  691. auth: '审核',
  692. allAuth: '所有权限',
  693. currentAuth: '当前权限',
  694. fieldAuthorization:'字段授权',
  695. role:'授权',
  696. },
  697. dataList: [],
  698. securityList: [],
  699. selectSpecialList: [],
  700. siteList: [],
  701. selectSitList: [],
  702. selectUser: {},
  703. pageIndex: 1,
  704. pageSize: 20,
  705. totalPage: 0,
  706. dataListLoading: false,
  707. dataListSelections: [],
  708. addOrUpdateVisible: false,
  709. functionFlag:false,
  710. functionList:[],
  711. rowFunctionId:'',
  712. selectFieldList:[],
  713. fieldList:[],
  714. fieldFlag:false,
  715. permissionFlag:false,
  716. }
  717. },
  718. components: {
  719. AddOrUpdate
  720. },
  721. activated() {
  722. this.getDataList()
  723. },
  724. mounted() {
  725. this.$nextTick(() => {
  726. this.securityHeight = window.innerHeight - 300;
  727. this.height = window.innerHeight - 200;
  728. })
  729. },
  730. methods: {
  731. // 获取button的词典
  732. getFunctionButtonList() {
  733. let queryButton = {
  734. functionId: this.$route.meta.menuId,
  735. tableId: '*',
  736. languageCode: this.$i18n.locale,
  737. objectType: 'button'
  738. }
  739. searchFunctionButtonList(queryButton).then(({data}) => {
  740. if (data.code == 0 && data.data) {
  741. this.buttons = data.data
  742. }
  743. })
  744. },
  745. /**
  746. * 列表表格选择替换
  747. * @param tab
  748. * @param event
  749. */
  750. tabClick (tab, event) {
  751. // 刷新列表数据
  752. this.refreshCurrentTabTable()
  753. },
  754. refreshCurrentTabTable() {
  755. if (this.activeTable === 'factory_information') {
  756. this.getUserAccessSiteInfoList()
  757. }
  758. if (this.activeTable === 'BU_information') {
  759. this.getUserAccessBUInfoList()
  760. }
  761. if (this.activeTable === 'project_information'){
  762. this.getUserAccessProjectInfoList()
  763. }
  764. if (this.activeTable === 'field_function_information'){
  765. this.getUserAccessFieldFunctionInfoList()
  766. }
  767. },
  768. // 特殊权限
  769. specialAuthorize() {
  770. this.specialVisible = true
  771. this.searchUserSpecialSecurity()
  772. },
  773. // 获取特殊权限
  774. searchUserSpecialSecurity() {
  775. saveUserSpecialSecurity({userid: this.selectUser.username}).then(({data}) => {
  776. if (data.code === 0) {
  777. getUserSpecialSecurity(this.selectUser.username).then(({data}) => {
  778. if (data.code === 0) {
  779. this.securityList = data.dataList.map(item => {
  780. item.itemvalue = item.itemvalue == 'Y' ? true : false;
  781. return item;
  782. })
  783. }
  784. })
  785. }
  786. })
  787. },
  788. // 保存用户权限
  789. saveUserSecurity() {
  790. let securityList = JSON.parse(JSON.stringify(this.securityList)).map(item => {
  791. item.itemvalue = item.itemvalue === true ? 'Y' : 'N';
  792. return item;
  793. })
  794. updateUserSpecialSecurity(securityList).then(({data}) => {
  795. if (data.code === 0) {
  796. this.$message.success(data.msg)
  797. this.specialVisible = false
  798. } else {
  799. this.$message.success(data.msg)
  800. }
  801. })
  802. },
  803. // 授权工厂
  804. siteAuthorize() {
  805. this.siteVisible = true
  806. this.searchSiteList()
  807. },
  808. buAuthorize() {
  809. this.buVisible = true
  810. this.searchBuList()
  811. },
  812. //授权项目start
  813. projectModel(){
  814. let inData={
  815. site:this.$store.state.user.site,
  816. username:this.selectUser.username,
  817. }
  818. searchAccessProjectForUser(inData).then(({data}) => {
  819. this.projectRoleList=data.rows
  820. })
  821. this.projectRoleFlag=true
  822. },
  823. changeAll(row){
  824. if(row.checkAll){
  825. row.searchCheck=true;
  826. row.updateCheck=true;
  827. row.downCheck=true;
  828. row.deleteCheck=true;
  829. row.searchFlag='Y'
  830. row.updateFlag='Y'
  831. row.downFlag='Y'
  832. row.deleteFlag='Y'
  833. }else {
  834. row.searchCheck=false;
  835. row.updateCheck=false;
  836. row.downCheck=false;
  837. row.deleteCheck=false;
  838. row.searchFlag='N'
  839. row.updateFlag='N'
  840. row.downFlag='N'
  841. row.deleteFlag='N'
  842. }
  843. },
  844. changeCheck(row,type){
  845. if(type==1){
  846. if(row.searchCheck){
  847. row.searchFlag='Y'
  848. }else {
  849. row.searchFlag='N'
  850. }
  851. }
  852. if(type==2){
  853. if(row.updateCheck){
  854. row.updateFlag='Y'
  855. }else {
  856. row.updateFlag='N'
  857. }
  858. }
  859. if(type==3){
  860. if(row.downCheck){
  861. row.downFlag='Y'
  862. }else {
  863. row.downFlag='N'
  864. }
  865. }
  866. if(type==4){
  867. if(row.deleteCheck){
  868. row.deleteFlag='Y'
  869. }else {
  870. row.deleteFlag='N'
  871. }
  872. }
  873. if(row.searchCheck&&row.updateCheck&&row.downCheck&&row.deleteCheck){
  874. row.checkAll=true
  875. }else{
  876. row.checkAll=false
  877. }
  878. this.$forceUpdate();
  879. },
  880. saveAccessProject(){
  881. let inData={
  882. site:this.$store.state.user.site,
  883. username:this.selectUser.username,
  884. accessProjectList:this.projectRoleList
  885. }
  886. saveAccessProject(inData).then(({data}) => {
  887. if (data && data.code === 0) {
  888. this.$message.success( '操作成功')
  889. this.projectRoleFlag = false
  890. } else {
  891. this.$message.error(data.msg)
  892. }
  893. })
  894. },
  895. //授权项目end
  896. // 保存选中的授权工厂
  897. saveUserAssessSite() {
  898. let accessSiteList = this.selectSitList.map(item => {
  899. let itemSite = {
  900. userid: this.selectUser.username,
  901. site: item
  902. }
  903. return itemSite;
  904. })
  905. let accessSite = {
  906. userid: this.selectUser.username,
  907. accessSiteList: accessSiteList
  908. }
  909. saveUserAccessSiteList(accessSite).then(({data}) => {
  910. if (data.code === 0) {
  911. this.$message.success(data.msg)
  912. this.siteList = []
  913. this.selectSitList = []
  914. this.siteVisible = false
  915. } else {
  916. this.$message.warning(data.msg)
  917. }
  918. })
  919. },
  920. saveBuAssessSite(){
  921. if(this.selectBUList.length==0){
  922. this.$message.warning("请选择BU")
  923. return false;
  924. }
  925. let inList=[];
  926. for (let i = 0; i < this.selectBUList.length; i++) {
  927. let inData={
  928. site:this.$store.state.user.site,
  929. username:this.selectUser.username,
  930. buNo:this.selectBUList[i]
  931. }
  932. inList.push(inData)
  933. }
  934. saveAccessBU(inList).then(({data}) => {
  935. if (data && data.code === 0) {
  936. this.$message.success( '操作成功')
  937. this.buVisible = false
  938. } else {
  939. this.$message.error(data.msg)
  940. }
  941. })
  942. },
  943. // 获取用户已授权的工厂列表
  944. searchUserAccessSiteList() {
  945. getUserAccessSiteList({userid: this.selectUser.username}).then(({data}) => {
  946. this.selectSitList = data.dataList
  947. })
  948. },
  949. // 获取所有可用工厂
  950. searchSiteList() {
  951. this.siteList=[]
  952. getSiteList({active: 'Y'}).then(({data}) => {
  953. if (data.code == 0) {
  954. this.siteList = data.dataList
  955. this.searchUserAccessSiteList()
  956. }
  957. })
  958. },
  959. searchBuList(){
  960. searchAccessBuList({site:this.$store.state.user.site,
  961. username: this.selectUser.username,
  962. active:'Y'}).then(({data}) => {
  963. this.selectBUList = data.selectBUList
  964. this.buList=data.buList
  965. })
  966. },
  967. // 选中行
  968. handleCurrentChange(val) {
  969. this.selectUser = val
  970. this.showButton = false
  971. },
  972. saveUserRoleFlag() {
  973. let saveList = []
  974. let currentList = this.checked
  975. // 当前未选择记录
  976. if (currentList.length == 0) {
  977. this.$confirm("当前未选择记录,是否继续?", '删除提示', {
  978. confirmButtonText: '确定',
  979. cancelButtonText: '取消',
  980. }).then(() => {
  981. let data = {
  982. userId: this.currentData.userId,
  983. }
  984. saveList.push(data);
  985. this.saveUserBusinessRole(saveList)
  986. }).catch(() => {
  987. return
  988. })
  989. } else {
  990. for (let i = 0; i < currentList.length; i++) {
  991. let data = {
  992. userId: this.currentData.userId,
  993. roleItemNo: currentList[i],
  994. selectFlag: 'Y',
  995. }
  996. saveList.push(data);
  997. }
  998. this.saveUserBusinessRole(saveList)
  999. }
  1000. },
  1001. saveUserBusinessRole(saveList) {
  1002. saveUserBusinessRole(saveList).then(({data}) => {
  1003. this.$alert(data.msg, '操作提示', {
  1004. confirmButtonText: '确定',
  1005. callback: action => {
  1006. if (data.code == 0) {
  1007. this.setUp.reviewFlag = false
  1008. }
  1009. this.setUp.saveButton = false
  1010. }
  1011. });
  1012. })
  1013. },
  1014. generateData(row) {
  1015. this.currentData = row
  1016. let queryData = {
  1017. active: 'Y',
  1018. userId: this.currentData.userId,
  1019. }
  1020. getUserBusinessRoleList(queryData).then(({data}) => {
  1021. let rows1Data = data.map.rows1
  1022. let rows2Data = data.map.rows2
  1023. let forData = []
  1024. let checkedList = []
  1025. for (let i = 0; i < rows1Data.length; i++) {
  1026. forData.push({
  1027. key: rows1Data[i].roleItemNo,
  1028. label: rows1Data[i].roleDesc,
  1029. });
  1030. }
  1031. for (let j = 0; j < rows2Data.length; j++) {
  1032. checkedList.push(rows2Data[j].roleItemNo)
  1033. }
  1034. this.transferData = forData;
  1035. this.checked = checkedList
  1036. this.setUp.reviewFlag = true
  1037. })
  1038. },
  1039. // 获取数据列表
  1040. getDataList: throttle(function () {
  1041. this.dataListLoading = true
  1042. this.$http({
  1043. url: this.$http.adornUrl('/sys/user/list'),
  1044. method: 'get',
  1045. params: this.$http.adornParams({
  1046. 'page': this.pageIndex,
  1047. 'limit': this.pageSize,
  1048. 'username': this.dataForm.userName
  1049. })
  1050. }).then(({data}) => {
  1051. if (data && data.code === 0) {
  1052. this.dataList = data.page.list
  1053. this.totalPage = data.page.totalCount
  1054. } else {
  1055. this.dataList = []
  1056. this.totalPage = 0
  1057. }
  1058. this.dataListLoading = false
  1059. })
  1060. }, 1000),
  1061. // 每页数
  1062. sizeChangeHandle(val) {
  1063. this.pageSize = val
  1064. this.pageIndex = 1
  1065. this.getDataList()
  1066. },
  1067. // 当前页
  1068. currentChangeHandle(val) {
  1069. this.pageIndex = val
  1070. this.getDataList()
  1071. },
  1072. // 多选
  1073. selectionChangeHandle(val) {
  1074. this.dataListSelections = val
  1075. },
  1076. // 权限清单模态框
  1077. permissionList(row) {
  1078. this.activeTable = 'factory_information'
  1079. this.userData = row
  1080. this.permissionFlag = true
  1081. },
  1082. // 获取用户工厂权限信息
  1083. getUserAccessSiteInfoList () {
  1084. getUserAccessSiteInfoList(this.userData).then(({data}) => {
  1085. if (data && data.code === 0) {
  1086. this.userSiteList = data.rows
  1087. } else {
  1088. this.$alert(data.msg, '错误', {
  1089. confirmButtonText: '确定'
  1090. })
  1091. }
  1092. })
  1093. },
  1094. // 获取用户BU权限信息
  1095. getUserAccessBUInfoList () {
  1096. getUserAccessBUInfoList(this.userData).then(({data}) => {
  1097. if (data && data.code === 0) {
  1098. this.userBUList = data.rows
  1099. } else {
  1100. this.$alert(data.msg, '错误', {
  1101. confirmButtonText: '确定'
  1102. })
  1103. }
  1104. })
  1105. },
  1106. // 获取用户项目权限信息
  1107. getUserAccessProjectInfoList () {
  1108. getUserAccessProjectInfoList(this.userData).then(({data}) => {
  1109. if (data && data.code === 0) {
  1110. this.userProjectList = data.rows
  1111. } else {
  1112. this.$alert(data.msg, '错误', {
  1113. confirmButtonText: '确定'
  1114. })
  1115. }
  1116. })
  1117. },
  1118. // 获取用户项目权限信息
  1119. getUserAccessFieldFunctionInfoList () {
  1120. getUserAccessFieldFunctionInfoList(this.userData).then(({data}) => {
  1121. if (data && data.code === 0) {
  1122. this.userFieldList = data.rows
  1123. } else {
  1124. this.$alert(data.msg, '错误', {
  1125. confirmButtonText: '确定'
  1126. })
  1127. }
  1128. })
  1129. },
  1130. // 新增 / 修改
  1131. addOrUpdateHandle(id) {
  1132. this.addOrUpdateVisible = true
  1133. this.$nextTick(() => {
  1134. this.$refs.addOrUpdate.init(id)
  1135. })
  1136. },
  1137. // 删除
  1138. deleteHandle(id) {
  1139. var userIds = id ? [id] : this.dataListSelections.map(item => {
  1140. return item.userId
  1141. })
  1142. this.$confirm(`确定对[id=${userIds.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
  1143. confirmButtonText: '确定',
  1144. cancelButtonText: '取消',
  1145. type: 'warning'
  1146. }).then(() => {
  1147. this.$http({
  1148. url: this.$http.adornUrl('/sys/user/delete'),
  1149. method: 'post',
  1150. data: this.$http.adornData(userIds, false)
  1151. }).then(({data}) => {
  1152. if (data && data.code === 0) {
  1153. this.$message.success('操作成功')
  1154. this.getDataList()
  1155. } else {
  1156. this.$message.error(data.msg)
  1157. }
  1158. })
  1159. }).catch(() => {
  1160. })
  1161. },
  1162. FieldListModel(){
  1163. searchFieldFunctionList().then(({data}) => {
  1164. this.functionList=data.rows
  1165. });
  1166. this.functionFlag=true;
  1167. },
  1168. accessModel(row){
  1169. this.rowFunctionId=row.functionId;
  1170. searchAccessFieldListByUser({functionId:row.functionId,
  1171. username: this.selectUser.username,
  1172. }).then(({data}) => {
  1173. this.selectFieldList = data.accessFieldList
  1174. this.fieldList=data.fieldList
  1175. })
  1176. this.fieldFlag=true;
  1177. },
  1178. saveAccessFieldListByUser(){
  1179. let inList=[];
  1180. for (let i = 0; i < this.selectFieldList.length; i++) {
  1181. let inData={
  1182. username: this.selectUser.username,
  1183. fieldId:this.selectFieldList[i]
  1184. }
  1185. inList.push(inData)
  1186. }
  1187. let saveData={
  1188. username: this.selectUser.username,
  1189. functionId:this.rowFunctionId,
  1190. accessFieldList:inList,
  1191. }
  1192. saveAccessFieldListByUser(saveData).then(({data}) => {
  1193. if (data && data.code === 0) {
  1194. this.$message.success( '操作成功')
  1195. this.fieldFlag = false
  1196. } else {
  1197. this.$message.error(data.msg)
  1198. }
  1199. })
  1200. },
  1201. closeDataDialog() {
  1202. this.userSiteList=[];
  1203. this.userBUList=[];
  1204. this.userProjectList=[];
  1205. this.userFieldList=[];
  1206. this.siteList=[];
  1207. this.selectSitList=[];
  1208. },
  1209. },
  1210. created() {
  1211. this.getFunctionButtonList()
  1212. }
  1213. }
  1214. </script>
  1215. <style>
  1216. .el-dialog__title {
  1217. line-height: 24px;
  1218. font-size: 16px;
  1219. color: #303133;
  1220. }
  1221. </style>