GroupsTaskAssignment.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <div class="communal-list" v-loading.fullscreen.lock="fullscreenLoading">
  3. <div class="communal-title">
  4. <div>团组任务分配</div>
  5. </div>
  6. <el-dialog title="批量分配" :visible.sync="batchVisible" :close-on-click-modal="false">
  7. <el-form ref="batch" :rules="batchs" :model="batch">
  8. <div class="batchbox">
  9. <el-form-item prop="TimePeriod" label="时间段" :label-width="formLabelWidth">
  10. <el-date-picker
  11. style="width:250px;"
  12. v-model="batch.TimePeriod"
  13. @change="TimePeriodchange"
  14. type="daterange"
  15. align="right"
  16. unlink-panels
  17. range-separator="至"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. :picker-options="pickerOptions">
  21. </el-date-picker>
  22. </el-form-item>
  23. <el-form-item prop="category" label="权限类型" :label-width="formLabelWidth">
  24. <el-select filterable multiple collapse-tags v-model="batch.category" placeholder="请选择权限类型">
  25. <el-option v-for=" item1 in setData" :key=item1.id :label=item1.name :value=item1.id></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item prop="person" label="人员" :label-width="formLabelWidth">
  29. <el-select filterable multiple collapse-tags v-model="batch.person" placeholder="请选择人员">
  30. <el-option v-for="( item, index ) in user " :key="index" :label="item.name" :value="item.id"></el-option>
  31. </el-select>
  32. </el-form-item>
  33. </div>
  34. <div class="batch">
  35. <el-button @click="CancelselectAll" size="mini">取消选择</el-button>
  36. <el-button @click="selectAll" type="primary" size="mini">全选</el-button>
  37. </div>
  38. <div class="checkbox-box">
  39. <el-checkbox-group @change="checkListchange" class="group-box" v-model="checkList">
  40. <el-checkbox style="width:45%;margin-bottom: 5px;" v-for="(item,index) in protogenesischeckList" :key="index" :label="item.teamName"></el-checkbox>
  41. </el-checkbox-group>
  42. </div>
  43. </el-form>
  44. <div slot="footer" class="dialog-footer">
  45. <el-button @click="batchVisible = false">取 消</el-button>
  46. <el-button type="primary" @click="submitForm('batch')">确 定</el-button>
  47. </div>
  48. </el-dialog>
  49. <div class="konzh" style="display: flex;justify-content: space-between;">
  50. <el-form style="display: flex;" label-width="70px" class="demo-form-inline">
  51. <el-form-item style="width: 300px;margin-right: 20px;" label="团组名称">
  52. <el-select v-model="diId" filterable :filter-method="advancedFilter" clearable placeholder="请选择" style="width:230px;"
  53. @change="diidChange()">
  54. <el-option v-for="item1 in delegationInfoss" :key=item1.id :label=item1.name
  55. :value=item1.id></el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item style="width: 300px;margin-right: 20px;" label="操作分类">
  59. <el-select v-model="ctId" filterable clearable placeholder="请选择" style="width:230px;"
  60. @change="sdIdChange()">
  61. <el-option v-for=" item1 in setData" :key=item1.id :label=item1.name :value=item1.id></el-option>
  62. </el-select>
  63. </el-form-item>
  64. </el-form>
  65. <!-- <div style="width: 240px;margin-right: 20px;">
  66. <el-select v-model="diId" filterable clearable placeholder="请选择" style="width:100%;"
  67. @change="diidChange()">
  68. <el-option v-for="item1 in delegationInfos" :key=item1.id :label=item1.name
  69. :value=item1.id></el-option>
  70. </el-select>
  71. </div>
  72. <div style="width: 200px;">
  73. <el-select v-model="ctId" filterable clearable placeholder="请选择" style="width:100%;"
  74. @change="sdIdChange()">
  75. <el-option v-for=" item1 in setData" :key=item1.id :label=item1.name :value=item1.id></el-option>
  76. </el-select>
  77. </div> -->
  78. <div style="width: 30%;text-align: right;">
  79. <el-button type="primary" style="margin-left: 10px;" @click="batchbtn">批量添加</el-button>
  80. <el-button type="primary" style="margin-left: 10px;" @click="btn">保存</el-button>
  81. </div>
  82. </div>
  83. <div class="tzinif-info">
  84. <div class="tzinif-info-li">
  85. <label>团 号:</label>
  86. <span>{{ DelegationInfo.tourCode }}</span>
  87. </div>
  88. <div class="tzinif-info-li">
  89. <label>客 户:</label>
  90. <span>{{ DelegationInfo.clientName }}</span>
  91. </div>
  92. <div class="tzinif-info-li">
  93. <label>出访国家:</label>
  94. <span>{{ DelegationInfo.visitCountry |filter_city}}</span>
  95. </div>
  96. <div class="tzinif-info-li">
  97. <label>起止日期:</label>
  98. <span>{{ DelegationInfo.visitStartDate|filter_time }}~{{ DelegationInfo.visitEndDate|filter_time}}</span>
  99. </div>
  100. <div class="tzinif-info-li">
  101. <label>天数/人数:</label>
  102. <span>{{ DelegationInfo.visitDays }}/{{ DelegationInfo.visitPNumber }}</span>
  103. </div>
  104. </div>
  105. <!-- <div class="tzinif">
  106. <span style="font-weight: bold;">团 号:</span>{{ DelegationInfo.tourCode }}
  107. <span style="font-weight: bold;">客 户:</span>{{ DelegationInfo.clientName }}
  108. <span style="font-weight: bold;">出访国家:</span>{{ DelegationInfo.visitCountry }}
  109. <span style="font-weight: bold;">起止日期:</span>{{ DelegationInfo.visitStartDate }} ~ {{
  110. DelegationInfo.visitEndDate }}
  111. <span style="font-weight: bold;">天数/人数:</span>{{ DelegationInfo.visitDays }}天/{{ DelegationInfo.visitPNumber }}人
  112. </div> -->
  113. <!-- <div>
  114. <div>人员安排</div>
  115. </div> -->
  116. <div style="margin-top: 10px;border-top: 1px solid #C0C4CC;">
  117. <div style="display: flex;flex-wrap: wrap;">
  118. <div v-for="( item, index ) in user "
  119. :key="index"
  120. style="width: 12.5%;margin: 10px 0;text-align: center;">
  121. <el-checkbox :label="item.id" :value="userStr.indexOf(item.id) != -1" border @change="check(item.id)"
  122. style="width: 120px;">{{
  123. item.name
  124. }}</el-checkbox>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. export default {
  132. data() {
  133. return {
  134. pickerOptions: {
  135. shortcuts: [{
  136. text: '最近一周',
  137. onClick(picker) {
  138. const end = new Date();
  139. const start = new Date();
  140. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  141. picker.$emit('pick', [start, end]);
  142. }
  143. }, {
  144. text: '最近一个月',
  145. onClick(picker) {
  146. const end = new Date();
  147. const start = new Date();
  148. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  149. picker.$emit('pick', [start, end]);
  150. }
  151. }, {
  152. text: '最近三个月',
  153. onClick(picker) {
  154. const end = new Date();
  155. const start = new Date();
  156. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  157. picker.$emit('pick', [start, end]);
  158. }
  159. }, {
  160. text: '最近一年',
  161. onClick(picker) {
  162. const end = new Date();
  163. const start = new Date();
  164. start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
  165. picker.$emit('pick', [start, end]);
  166. }
  167. }]
  168. },
  169. rules: {},
  170. token: '',
  171. userId: 0,
  172. delegationInfos: [],
  173. delegationInfoss: [],
  174. searchMode: 'character', // 'character': 字符匹配, 'fuzzy': 模糊匹配
  175. setData: [],
  176. user: [],
  177. diId: '',
  178. ctId: '',
  179. userStr: [],
  180. TaskAssignment: {},
  181. DelegationInfo: {},
  182. fullscreenLoading:false,
  183. formLabelWidth:"80px",
  184. batch:{
  185. TimePeriod:[],
  186. person:[],
  187. category:[]
  188. },
  189. batchs: {
  190. TimePeriod: [
  191. { required: true, message: '请选着日期', trigger: 'blur' },
  192. ],
  193. person: [
  194. { required: true, message: '请选择人员', trigger: 'blur' },
  195. ],
  196. category: [
  197. { required: true, message: '请选择权限类型', trigger: 'blur' },
  198. ],
  199. },
  200. batchVisible:false,
  201. checkList:[],
  202. protogenesischeckList:[],
  203. uploadingcheckList:[]
  204. }
  205. },
  206. methods: {
  207. advancedFilter(query) {
  208. console.log(query);
  209. if (!query || query.trim() === '') {
  210. this.delegationInfoss = [...this.delegationInfos];
  211. return;
  212. }
  213. const trimmedQuery = query.trim();
  214. if (this.searchMode === 'character') {
  215. // 字符匹配模式:每个字都必须包含
  216. this.characterMatchFilter(trimmedQuery);
  217. } else {
  218. // 模糊匹配模式(默认的filterable行为)
  219. this.fuzzyMatchFilter(trimmedQuery);
  220. }
  221. },
  222. /*** 严格的字符匹配 - 每个查询字符都必须出现*/
  223. characterMatchFilter(query) {
  224. const queryChars = query.split('').filter(char => char.trim() !== '');
  225. this.delegationInfoss = this.delegationInfos.filter(item => {
  226. const groupName = item.name || '';
  227. return queryChars.every(char => groupName.includes(char));
  228. });
  229. },
  230. /*** 模糊匹配 - 包含整个查询字符串即可*/
  231. fuzzyMatchFilter(query) {
  232. const lowerQuery = query.toLowerCase();
  233. this.delegationInfoss = this.delegationInfos.filter(item => {
  234. const groupName = (item.name || '').toLowerCase();
  235. return groupName.includes(lowerQuery);
  236. });
  237. },
  238. GetTaskAssignmen() {
  239. this.fullscreenLoading=true;
  240. var that = this
  241. var url = "/api/Groups/GetTaskAssignmen";
  242. this.$axios({
  243. method: 'post',
  244. url: url,
  245. headers: {
  246. Authorization: 'Bearer ' + this.token
  247. },
  248. }).then(function (res) {
  249. console.log(res)
  250. if (res.data.code == 200) {
  251. that.delegationInfos = res.data.data.delegationInfos;
  252. that.delegationInfoss = that.delegationInfos;
  253. that.diId=res.data.data.delegationInfos[0].id;
  254. that.setData = res.data.data.setData;
  255. that.setData = that.setData.filter(function(item) {
  256. return item.name !== "文档下载"&&item.name !== "会务相关"
  257. });
  258. that.ctId=res.data.data.setData[0].id;
  259. that.user = res.data.data.user;
  260. setTimeout(() => {
  261. that.TaskAssignmenQuery();
  262. }, 500);
  263. console.log(that.setData)
  264. }
  265. })
  266. },
  267. //处理时间
  268. getdate(val){
  269. var date=new Date(val);
  270. var y=date.getFullYear();
  271. var m=date.getMonth()+1<10?'0'+(date.getMonth()+1):date.getMonth()+1;
  272. var d=date.getDate()<10?'0'+date.getDate():date.getDate();
  273. return y+'-'+m+'-'+d
  274. },
  275. //取消全选
  276. CancelselectAll(){
  277. this.checkList=[];
  278. this.uploadingcheckList=[];
  279. },
  280. //全选
  281. selectAll(){
  282. for(let i=0;i<this.protogenesischeckList.length;i++){
  283. this.checkList.push(this.protogenesischeckList[i].teamName)
  284. }
  285. this.acquireid()
  286. },
  287. //团组checkbox值改变
  288. checkListchange(){
  289. this.acquireid();
  290. },
  291. //时间段切换
  292. TimePeriodchange(){
  293. this.TaskAllocationGroupSelect()
  294. },
  295. //获取时间段数组
  296. TaskAllocationGroupSelect() {
  297. var that = this
  298. var url = "/api/Groups/TaskAllocationGroupSelect";
  299. this.$axios({
  300. method: 'post',
  301. url: url,
  302. data: {
  303. portType: 1,
  304. visitBeginDt: that.getdate(that.batch.TimePeriod[0]),
  305. visitEndDt: that.getdate(that.batch.TimePeriod[1]),
  306. },
  307. headers: {
  308. Authorization: 'Bearer '
  309. },
  310. }).then(function (res) {
  311. if (res.data.code == 200) {
  312. that.protogenesischeckList=res.data.data;
  313. } else {
  314. }
  315. })
  316. },
  317. //获取选择团组id
  318. acquireid(){
  319. this.uploadingcheckList=[];
  320. for(let j=0;j<this.checkList.length;j++){
  321. for(let i=0;i<this.protogenesischeckList.length;i++){
  322. if(this.checkList[j]==this.protogenesischeckList[i].teamName){
  323. this.uploadingcheckList.push(this.protogenesischeckList[i].id)
  324. }
  325. }
  326. }
  327. },
  328. batchbtn(){
  329. this.batchVisible=true;
  330. this.batch.TimePeriod=[];
  331. this.batch.person=[];
  332. this.batch.category=[];
  333. this.checkList=[];
  334. this.protogenesischeckList=[];
  335. this.uploadingcheckList=[];
  336. },
  337. //保存api
  338. TaskAllocationBulkAdd() {
  339. if(this.uploadingcheckList.length<1){
  340. this.$message.error('保存失败!未选择团组。');
  341. return
  342. }
  343. var that = this
  344. var url = "/api/Groups/TaskAllocationBulkAdd";
  345. this.$axios({
  346. method: 'post',
  347. url: url,
  348. data: {
  349. userIds: that.batch.person,
  350. permissionTypeIds: that.batch.category,
  351. groupIds: that.uploadingcheckList,
  352. currUserId: that.userId,
  353. },
  354. headers: {
  355. Authorization: 'Bearer ' + this.token
  356. },
  357. }).then(function (res) {
  358. if (res.data.code == 200) {
  359. that.$message({
  360. message: res.data.msg,
  361. type: 'success'
  362. });
  363. } else {
  364. that.$message.error(res.data.msg);
  365. }
  366. })
  367. },
  368. //保存
  369. submitForm(batch) {
  370. this.$refs[batch].validate((valid) => {
  371. if (valid) {
  372. this.TaskAllocationBulkAdd()
  373. } else {
  374. console.log('error submit!!');
  375. return false;
  376. }
  377. });
  378. },
  379. TaskAssignmenQuery() {
  380. var that = this
  381. var url = "/api/Groups/TaskAssignmenQuery";
  382. this.$axios({
  383. method: 'post',
  384. url: url,
  385. data: {
  386. diId: that.diId,
  387. ctId: that.ctId,
  388. },
  389. headers: {
  390. Authorization: 'Bearer ' + this.token
  391. },
  392. }).then(function (res) {
  393. if (res.data.code == 200) {
  394. that.userStr = res.data.data.userStr
  395. that.TaskAssignment = res.data.data.taskAssignment
  396. that.DelegationInfo = res.data.data.delegationInfo
  397. that.fullscreenLoading=false;
  398. } else {
  399. that.userStr = [];
  400. that.TaskAssignment = {};
  401. that.DelegationInfo = {}
  402. that.fullscreenLoading=false;
  403. }
  404. })
  405. },
  406. btn() {
  407. var id = 0
  408. var that = this;
  409. if (that.TaskAssignment.id != undefined) {
  410. id = that.TaskAssignment.id;
  411. }
  412. var url = "/api/Groups/GetTaskAssignmenOp";
  413. this.$axios({
  414. method: 'post',
  415. url: url,
  416. data: {
  417. diId: that.diId,
  418. ctId: that.ctId,
  419. uIdStr: that.userStr,
  420. isEnable: 1,
  421. createUserId: that.userId,
  422. remark: ""
  423. },
  424. headers: {
  425. Authorization: 'Bearer ' + that.token
  426. },
  427. }).then(function (res) {
  428. if (res.data.code == 200) {
  429. that.$message({
  430. message: '保存成功!',
  431. type: 'success'
  432. });
  433. } else {
  434. that.$message.error('保存失败!' + res.data.msg);
  435. }
  436. })
  437. },
  438. diidChange() {
  439. this.userStr = [];
  440. this.TaskAssignmenQuery()
  441. console.log(this.userStr)
  442. },
  443. sdIdChange() {
  444. this.TaskAssignmenQuery()
  445. console.log(this.userStr)
  446. },
  447. check(id) {
  448. var index = this.userStr.indexOf(id)
  449. if (index == -1) {
  450. this.userStr.push(id)
  451. } else {
  452. this.userStr = this.userStr.filter((x) => x !== id)
  453. }
  454. }
  455. },
  456. filters:{
  457. filter_city(value){
  458. if(value){
  459. return value.replaceAll('|','、')
  460. }
  461. },
  462. filter_time(value){
  463. if(value){
  464. return value.split(" ")[0]
  465. }
  466. }
  467. },
  468. mounted() {
  469. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  470. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  471. this.GetTaskAssignmen();
  472. }
  473. }
  474. </script>
  475. <style>
  476. .communal-list {
  477. background-color: #fff;
  478. padding: 10px;
  479. box-shadow: 0 0 5px #0005;
  480. border-radius: 10px;
  481. min-height: 820px;
  482. }
  483. .communal-title {
  484. display: flex;
  485. font-size: 17px;
  486. font-weight: 600;
  487. color: #555;
  488. margin-bottom: 15px;
  489. justify-content: space-between;
  490. align-items: center;
  491. }
  492. .communal-box {
  493. display: flex;
  494. }
  495. .communal-box>button {
  496. margin-left: 10px;
  497. padding: 8px 20px;
  498. }
  499. .tzinif-info {
  500. display: flex;
  501. margin-top: 10px;
  502. }
  503. .tzinif-info-li {
  504. margin-right: 30px;
  505. }
  506. .tzinif-info-li label {
  507. color: #606266;
  508. font-size: 15px;
  509. font-weight: 600;
  510. }
  511. .tzinif-info-li span {
  512. color: #606266;
  513. font-size: 14px;
  514. }
  515. .konzh .el-form-item{
  516. margin-bottom: 0;
  517. }
  518. .batchbox{
  519. display: flex;
  520. justify-content: space-between;
  521. }
  522. .checkbox-box{
  523. padding: 10px;
  524. border: 1px solid #DCDFE6 ;
  525. height: 360px;
  526. overflow-y: auto;
  527. }
  528. .batch{
  529. text-align: right;
  530. margin-bottom: 10px;
  531. }
  532. .group-box{
  533. display: flex;
  534. flex-wrap: wrap;
  535. }
  536. </style>