index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <el-form class="bf-rulesofcompetency">
  3. <!-- 权限规则 -->
  4. <div class="right">
  5. <div class="paren_header">
  6. <p class="manageTitle">{{ title }}</p>
  7. <!-- <div class="header_right">
  8. <el-radio v-model="form.radio" :label="item.id" v-for="(item, index) in option" :key="index">{{ item.label }}</el-radio>
  9. </div> -->
  10. </div>
  11. <div class="form">
  12. <!-- <div class="juris_list" :style="{ marginBottom: marginB }">
  13. <p>时效范围起</p>
  14. <el-date-picker v-model="form.firstWeeks" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择时间" size="small" :picker-options="pickerOptionsStart">
  15. </el-date-picker>
  16. </div>
  17. <div class="juris_list" :style="{ marginBottom: marginB }">
  18. <p>时效范围至</p>
  19. <el-date-picker @change="setTime" v-model="form.endWeeks" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择时间" size="small" :picker-options="pickerOptionsEnd">
  20. </el-date-picker>
  21. </div> -->
  22. <div class="juris_list" :style="{ marginBottom: marginB }">
  23. <p>许可查询行</p>
  24. <el-input v-model="form.query_row_condition" placeholder="请输入内容" size="small"></el-input>
  25. </div>
  26. <div class="juris_list" :style="{ marginBottom: marginB }">
  27. <p>许可查询列</p>
  28. <el-input v-model="form.query_col_conditon" placeholder="请输入内容" size="small"></el-input>
  29. </div>
  30. <div class="juris_list" :style="{ marginBottom: marginB }">
  31. <p>许可删除行</p>
  32. <el-input v-model="form.delete_row_condition" placeholder="请输入内容" size="small"></el-input>
  33. </div>
  34. <div class="juris_list" :style="{ marginBottom: marginB }">
  35. <p>许可新增列</p>
  36. <el-input v-model="form.new_col_condition" placeholder="请输入内容" size="small"></el-input>
  37. </div>
  38. <div class="juris_list" :style="{ marginBottom: marginB }">
  39. <p>许可编辑行</p>
  40. <el-input v-model="form.edit_row_condition" placeholder="请输入内容" size="small"></el-input>
  41. </div>
  42. <div class="juris_list" :style="{ marginBottom: marginB }">
  43. <p>许可编辑列</p>
  44. <el-input v-model="form.edit_col_condition" placeholder="请输入内容" size="small"></el-input>
  45. </div>
  46. </div>
  47. </div>
  48. </el-form>
  49. </template>
  50. <script>
  51. export default {
  52. props: {
  53. title: {
  54. type: String,
  55. default: " ",
  56. },
  57. marginB: {
  58. type: String,
  59. default: "24px",
  60. },
  61. authTo: {
  62. type: Object,
  63. default: () => { },
  64. },
  65. authList: {
  66. type: Array,
  67. default: () => [],
  68. },
  69. },
  70. data () {
  71. return {
  72. form: {
  73. query_row_condition: "",
  74. query_col_conditon: "",
  75. delete_row_condition: "",
  76. new_col_condition: "",
  77. edit_row_condition: "",
  78. edit_col_condition: ""
  79. },
  80. option: [
  81. {
  82. label: "显示权限",
  83. id: 1,
  84. },
  85. {
  86. label: "显示及编辑权限",
  87. id: 2,
  88. },
  89. ],
  90. };
  91. },
  92. watch: {
  93. authTo: {
  94. handler (obj) {
  95. // this.form = _.cloneDeep(obj)
  96. this.$store.dispatch("auth/changeAuthId", obj.auth_id)
  97. },
  98. deep: true,
  99. },
  100. form: {
  101. handler () {
  102. this.getData();
  103. },
  104. deep: true,
  105. },
  106. authList: {
  107. handler (arr) {
  108. this.$store.dispatch("auth/changeAuthList", arr);
  109. // this.$store.dispatch("auth/changeAuthMsg", arr);
  110. // this.$store.dispatch("auth/changeAuthArrs", arr);
  111. },
  112. deep: true,
  113. },
  114. "$store.state.auth.authMsg": {
  115. handler (arr) {
  116. const id = this.$store.getters.authId;
  117. const obj = arr.filter((item) => item.auth_id === id)[0];
  118. this.clearFormData();
  119. this.setFormData(_.cloneDeep(obj));
  120. },
  121. deep: true,
  122. }
  123. },
  124. methods: {
  125. getData () {
  126. const obj = _.cloneDeep(this.form);
  127. this.$emit("getData", obj);
  128. const arr = this.$store.getters.authArrs;
  129. const datas = _.unionBy(arr, "auth_id");
  130. const id = this.$store.getters.authId;
  131. // console.log(datas)
  132. if (datas.length) {
  133. // const dat = datas[datas.length - 1]
  134. let dat = datas[datas.length - 1];
  135. datas.map((item) => {
  136. if (item.auth_id == id) {
  137. dat = item;
  138. }
  139. });
  140. const { auth_id } = dat;
  141. obj["AuthId"] = auth_id;
  142. datas.forEach((item) => {
  143. if (item.auth_id == id) {
  144. item.AuthList = obj;
  145. }
  146. });
  147. this.$store.dispatch("auth/changeAuthArrs", datas);
  148. }
  149. },
  150. clearFormData () {
  151. this.form.query_row_condition = "";
  152. this.form.query_col_conditon = "";
  153. this.form.delete_row_condition = "";
  154. this.form.new_col_condition = "";
  155. this.form.edit_row_condition = "";
  156. this.form.edit_col_condition = "";
  157. },
  158. setFormData (obj) {
  159. let data = {};
  160. if (obj.AuthList) {
  161. data = obj.AuthList;
  162. } else {
  163. data = obj;
  164. }
  165. this.form = _.cloneDeep(data);
  166. },
  167. },
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. @import "./rulesofcompetency.scss";
  172. .el-picker-panel {
  173. > .el-picker-panel__footer {
  174. > .el-button--text {
  175. display: none;
  176. }
  177. }
  178. }
  179. </style>