remindSet.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="all">
  3. <div class="flex-box-ce">
  4. <div class="flex-1">
  5. <div class="title">指定分组</div>
  6. <div class="text fontColorB">可添加30个分组,每组最多设置50人</div>
  7. </div>
  8. <el-button size="small" type="primary" @click="openAdd()"><i class="el-icon-plus"></i>添加分组</el-button>
  9. </div>
  10. <div class="table-box" style="margin-top: 20px;">
  11. <el-table :data="AdministratorList" style="width: 800px;" v-loading="loading">
  12. <el-table-column prop="name" label="名称" width="300"></el-table-column>
  13. <el-table-column label="人员">
  14. <template slot-scope="scope">
  15. <Tooltip v-if="scope.row.names" :preHtml="scope.row.names"><span>{{scope.row.names}}</span></Tooltip>
  16. <div v-else>--</div>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="操作" width="100">
  20. <template slot-scope="scope">
  21. <el-button @click="openAdd(scope.row)" type="text" class="blue">编辑</el-button>
  22. <el-button @click="deleteUser(scope.row.id)" type="text" class="red">删除</el-button>
  23. </template>
  24. </el-table-column>
  25. </el-table>
  26. </div>
  27. <el-dialog :title="addFormData.id? '设置分组':'添加分组'" :visible.sync="isShowAdd" :close-on-click-modal="false" width="700px">
  28. <div style="padding: 20px;padding-bottom: 0;">
  29. <el-form :model="addFormData" ref="addFormData" label-width="120px" class="form">
  30. <el-form-item label="分组名称" prop="name" :rules="[{ required: true, message: '请填写分组名称'}, { min: 2, max: 20, message: '长度在 2 到 20 个字符'}]" >
  31. <el-input style="width: 500px;" v-model="addFormData.name" placeholder="请输入分组名称(限20字)" maxlength="20" show-word-limit></el-input>
  32. </el-form-item>
  33. <el-form-item label="人员" prop="base_point">
  34. <div class="border flex-box-ce" style="margin-top: 5px;">
  35. <div class="flex-1">
  36. <div class="fontColorB font-flex-word" style="width: 430px;" v-if="employee_selected_all.employee.length>0">
  37. <span v-for="item in employee_selected_all.employee" :key="item.id">{{item.name}},</span>
  38. </div>
  39. <span v-else>选择所属人员</span>
  40. </div>
  41. <i class="el-icon-arrow-down icon-right"></i>
  42. <div class="inputDc" @click="show_employee_selector_all=true"></div>
  43. </div>
  44. </el-form-item>
  45. </el-form>
  46. <div class="flex-box-end" style="margin-top: 40px;">
  47. <el-button @click="isShowAdd=false">取消</el-button>
  48. <el-button type="primary" @click="confirmAdd('addFormData')">提交</el-button>
  49. </div>
  50. </div>
  51. </el-dialog>
  52. <!-- 选择负责人 -->
  53. <EmployeeSelector
  54. :is_filtration_creator="false"
  55. title="选择人员"
  56. :max="50"
  57. :isChecKedAll="false"
  58. :selected="employee_selected_all"
  59. :visible.sync="show_employee_selector_all"
  60. @confirm="employee_confirm_all"
  61. />
  62. </div>
  63. </template>
  64. <script>
  65. import EmployeeSelector from '@/components/EmployeeSelector';
  66. import Tooltip from '@/components/Tooltip'; //鼠标悬浮显示文字
  67. export default {
  68. components: { EmployeeSelector,Tooltip },
  69. name: 'JurisdictionSet',
  70. data() {
  71. return {
  72. loading: false,
  73. isShowAdd:false,
  74. AdministratorList:[],
  75. userInfo: this.$userInfo(),
  76. addFormData:{
  77. name:'',
  78. employee_ids:[]
  79. },
  80. employee_selected_all: { dept: [], employee: [] },
  81. show_employee_selector_all: false,
  82. };
  83. },
  84. created() {
  85. this.getList();
  86. },
  87. methods: {
  88. openAdd(item){
  89. if(item){
  90. this.addFormData={
  91. id:item.id,
  92. name:item.name,
  93. employee_ids:item.employee_ids
  94. };
  95. this.employee_selected_all.employee=item.employee_ids.map(item=>{
  96. return this.$getEmployeeMapItem(item)
  97. })
  98. this.isShowAdd = true;
  99. }else{
  100. if(this.AdministratorList.length>=30){
  101. this.$message.error('分组最多为30个');
  102. return false
  103. }
  104. this.addFormData={
  105. name:'',
  106. employee_ids:''
  107. };
  108. this.employee_selected_all.employee=[];
  109. this.isShowAdd = true;
  110. }
  111. },
  112. confirmAdd(formName){
  113. this.$refs[formName].validate(valid => {
  114. if (valid) {
  115. this.addFormData.employee_ids=this.addFormData.employee_ids.toString();
  116. if(this.addFormData.id){
  117. var http1 = this.$axiosUser('POST','/api/pro/sm/group/name',this.addFormData); // 名称
  118. var http2 = this.$axiosUser('POST','/api/pro/sm/group/employee',this.addFormData); // 日期
  119. Promise.all([http1, http2]).then(res => {
  120. this.$message.success('已编辑');
  121. this.getList();
  122. }).finally(() => {
  123. this.isShowAdd = false;
  124. })
  125. }else{
  126. this.$axiosUser('post','api/pro/sm/group/create', this.addFormData).then(res => {
  127. this.$message.success('已添加');
  128. this.getList();
  129. }).finally(() => {
  130. this.isShowAdd = false;
  131. });
  132. }
  133. }
  134. })
  135. },
  136. deleteUser(id) {
  137. this.$confirm('确定删除该分组?', '提示', {
  138. confirmButtonText: '确定',
  139. cancelButtonText: '取消',
  140. type: 'warning'
  141. }).then(() => {
  142. this.$axiosUser('post', '/api/pro/sm/group/delete', { id: id }).then(res => {
  143. this.$message.success('删除成功');
  144. this.getList();
  145. });
  146. }).catch(() => {});
  147. },
  148. getList(){
  149. this.loading=false;
  150. this.$axiosUser('get', '/api/pro/sm/group').then(res => {
  151. let list=res.data.data.list;
  152. list.forEach(item=>{
  153. if(item.employee_ids.length>0){
  154. let names='';
  155. item.employee_ids.forEach(e=>{
  156. names+=this.$getEmployeeMapItem(e).name+','
  157. })
  158. item.names=names
  159. }
  160. })
  161. this.AdministratorList=list;
  162. }).finally(()=>{
  163. this.loading=false;
  164. });
  165. },
  166. employee_confirm_all(val){
  167. this.employee_selected_all.employee=val.employee;
  168. this.addFormData.employee_ids=val.employee.map(item=>{
  169. return item.id
  170. })
  171. },
  172. }
  173. };
  174. </script>
  175. <style scoped="scoped">
  176. .all {
  177. min-height: calc(100vh - 210px);
  178. overflow: auto;
  179. padding: 10px;
  180. }
  181. .title {
  182. font-size: 18px;
  183. font-weight: 500;
  184. margin-bottom: 10px;
  185. }
  186. .name {
  187. padding-left: 10px;
  188. }
  189. .title-f {
  190. margin-bottom: 20px;
  191. }
  192. .border {
  193. -webkit-appearance: none;
  194. background-color: #fff;
  195. background-image: none;
  196. border-radius: 4px;
  197. border: 1px solid #dcdfe6;
  198. -webkit-box-sizing: border-box;
  199. box-sizing: border-box;
  200. color: #C0C4CF;
  201. font-size: inherit;
  202. height: auto;
  203. outline: 0;
  204. padding: 0 15px;
  205. padding-right: 10px;
  206. line-height: 34px;
  207. width: 500px;
  208. position: relative;
  209. cursor: pointer;
  210. }
  211. .border .font-flex-word{
  212. color: #606266;
  213. }
  214. .border:hover{
  215. border: 1px solid #c0c4cc;
  216. }
  217. .inputDc {
  218. position: absolute;
  219. top: 0;
  220. right: 0;
  221. left: 0;
  222. bottom: 0;
  223. z-index: 9;
  224. cursor: pointer;
  225. }
  226. .checkChild {
  227. background-color: #fbfdff;
  228. margin-left: 20px;
  229. }
  230. .li {
  231. border-bottom: 1px solid #f1f1f1;
  232. }
  233. .li:hover {
  234. background-color: #f5f7fa;
  235. }
  236. .ul {
  237. margin: 20px 0;
  238. margin-top: 10px;
  239. }
  240. </style>