index copy.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <el-form class="bf-rulesofcompetency">
  3. <!-- 权限规则 -->
  4. <div class="right">
  5. <div class="paren_header">
  6. <p>{{ title }}</p>
  7. <div class="header_right">
  8. <el-radio
  9. v-model="form.Action"
  10. :label="item.id"
  11. v-for="(item, index) in option"
  12. :key="index"
  13. >{{ item.label }}</el-radio
  14. >
  15. </div>
  16. </div>
  17. <div>
  18. <span>{{name}}</span>
  19. </div>
  20. <div class="juris_list" :style="{ marginBottom: marginB }">
  21. <p>时效范围起</p>
  22. <el-date-picker
  23. v-model="form.ValidBegin"
  24. type="datetime"
  25. value-format="yyyy-MM-dd HH:mm:ss"
  26. placeholder="选择时间"
  27. size="mini"
  28. :picker-options="pickerOptionsStart"
  29. >
  30. </el-date-picker>
  31. </div>
  32. <div class="juris_list" :style="{ marginBottom: marginB }">
  33. <p>至</p>
  34. <el-date-picker
  35. @change="setTime"
  36. v-model="form.ValidEnd"
  37. value-format="yyyy-MM-dd HH:mm:ss"
  38. type="datetime"
  39. placeholder="选择时间"
  40. size="mini"
  41. :picker-options="pickerOptionsEnd"
  42. >
  43. </el-date-picker>
  44. </div>
  45. <div class="juris_list" :style="{ marginBottom: marginB }">
  46. <p>许可查询行</p>
  47. <el-input
  48. v-model="form.QueryRow"
  49. placeholder="请输入内容"
  50. size="mini"
  51. ></el-input>
  52. </div>
  53. <div class="juris_list" :style="{ marginBottom: marginB }">
  54. <p>许可查询列</p>
  55. <el-input
  56. v-model="form.QueryCol"
  57. placeholder="请输入内容"
  58. size="mini"
  59. ></el-input>
  60. </div>
  61. <div class="juris_list" :style="{ marginBottom: marginB }">
  62. <p>许可删除行</p>
  63. <el-input
  64. v-model="form.DeleteRow"
  65. placeholder="请输入内容"
  66. size="mini"
  67. ></el-input>
  68. </div>
  69. <div class="juris_list" :style="{ marginBottom: marginB }">
  70. <p>许可新增列</p>
  71. <el-input
  72. v-model="form.NewCol"
  73. placeholder="请输入内容"
  74. size="mini"
  75. ></el-input>
  76. </div>
  77. <div class="juris_list" :style="{ marginBottom: marginB }">
  78. <p>许可编辑行</p>
  79. <el-input
  80. v-model="form.EditRow"
  81. placeholder="请输入内容"
  82. size="mini"
  83. ></el-input>
  84. </div>
  85. <div class="juris_list" :style="{ marginBottom: marginB }">
  86. <p>许可编辑列</p>
  87. <el-input
  88. v-model="form.EditCol"
  89. placeholder="请输入内容"
  90. size="mini"
  91. ></el-input>
  92. </div>
  93. </div>
  94. </el-form>
  95. </template>
  96. <script>
  97. export default {
  98. props: {
  99. title: {
  100. type: String,
  101. default: " ",
  102. },
  103. marginB: {
  104. type: String,
  105. default: "24px",
  106. },
  107. authTo: {
  108. type: Object,
  109. default: () => {},
  110. },
  111. authList: {
  112. type: Array,
  113. default: () => [],
  114. },
  115. },
  116. data() {
  117. return {
  118. name:"",
  119. pickerOptionsStart: {
  120. disabledDate: (time) => {
  121. if (this.endWeeks) {
  122. return time.getTime() >= new Date(this.endWeeks).getTime();
  123. }
  124. },
  125. },
  126. pickerOptionsEnd: {
  127. disabledDate: (time) => {
  128. if (this.firstWeeks) {
  129. return (
  130. time.getTime() <= new Date(this.firstWeeks).getTime() - 86400000
  131. );
  132. }
  133. },
  134. },
  135. form: {
  136. AuthId:null,
  137. DeleteRow: null,
  138. EditCol: null,
  139. Action: null,
  140. EditRow: null,
  141. NewCol: null,
  142. QueryCol: null,
  143. QueryRow: null,
  144. ValidBegin: null,
  145. ValidEnd: null,
  146. },
  147. option: [
  148. {
  149. label: "显示权限",
  150. id: 1,
  151. },
  152. {
  153. label: "显示及编辑权限",
  154. id: 2,
  155. },
  156. ],
  157. oldVal: null,
  158. };
  159. },
  160. watch: {
  161. "$store.state.auth.authId": {
  162. handler(val) {
  163. if (val && val.AuthId && this.oldVal == null) {
  164. this.oldVal = val;
  165. this.getFormData(val.AuthId);
  166. this.name = val.AuthName;
  167. }
  168. if (val && val.AuthId && this.oldVal != null) {
  169. if (val.AuthId != this.oldVal.AuthId) {
  170. this.name = val.AuthName;
  171. this.setAuthListData(val);
  172. }
  173. }
  174. },
  175. deep: true,
  176. },
  177. },
  178. methods: {
  179. getFormData(id) {
  180. this.form = {
  181. AuthId:null,
  182. DeleteRow: null,
  183. EditCol: null,
  184. Action: null,
  185. EditRow: null,
  186. NewCol: null,
  187. QueryCol: null,
  188. QueryRow: null,
  189. ValidBegin: null,
  190. ValidEnd: null,
  191. }
  192. let list = this.$store.state.auth.authList;
  193. // console.log(list)
  194. let idArr = [];
  195. list.forEach((item) => {
  196. // console.log(item)
  197. if(item!=null){
  198. idArr.push(item.AuthId);
  199. }
  200. else{
  201. idArr.push(null);
  202. }
  203. });
  204. let index = idArr.indexOf(id);
  205. if(index>-1){
  206. this.form = this.$store.state.auth.authList[index];
  207. }
  208. else{
  209. this.form.AuthId = id;
  210. }
  211. console.log( this.form)
  212. },
  213. setAuthListData(data) {
  214. let list = this.$store.state.auth.authList;
  215. let idArr = [];
  216. list.forEach((item) => {
  217. if(item.AuthId){
  218. idArr.push(item.AuthId);
  219. }
  220. else{
  221. idArr.push(null);
  222. }
  223. });
  224. let index = idArr.indexOf(this.oldVal.AuthId);
  225. if(index>-1){
  226. this.$store.state.auth.authList[index] = this.form;
  227. }
  228. else{
  229. this.$store.state.auth.authList.push(this.form)
  230. }
  231. this.oldVal = data;
  232. this.getFormData(data.AuthId);
  233. },
  234. setTime(val) {
  235. if (this.endWeeks < this.firstWeeks) {
  236. this.endWeeks = "";
  237. }
  238. },
  239. },
  240. };
  241. </script>
  242. <style lang="scss" scoped>
  243. @import "./rulesofcompetency.scss";
  244. .el-picker-panel {
  245. > .el-picker-panel__footer {
  246. > .el-button--text {
  247. display: none;
  248. }
  249. }
  250. }
  251. </style>