GroupsTaskAssignment.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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 clearable placeholder="请选择" style="width:230px;"
  53. @change="diidChange()">
  54. <el-option v-for="item1 in delegationInfos" :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. setData: [],
  174. user: [],
  175. diId: '',
  176. ctId: '',
  177. userStr: [],
  178. TaskAssignment: {},
  179. DelegationInfo: {},
  180. fullscreenLoading:false,
  181. formLabelWidth:"80px",
  182. batch:{
  183. TimePeriod:[],
  184. person:[],
  185. category:[]
  186. },
  187. batchs: {
  188. TimePeriod: [
  189. { required: true, message: '请选着日期', trigger: 'blur' },
  190. ],
  191. person: [
  192. { required: true, message: '请选择人员', trigger: 'blur' },
  193. ],
  194. category: [
  195. { required: true, message: '请选择权限类型', trigger: 'blur' },
  196. ],
  197. },
  198. batchVisible:false,
  199. checkList:[],
  200. protogenesischeckList:[],
  201. uploadingcheckList:[]
  202. }
  203. },
  204. methods: {
  205. GetTaskAssignmen() {
  206. this.fullscreenLoading=true;
  207. var that = this
  208. var url = "/api/Groups/GetTaskAssignmen";
  209. this.$axios({
  210. method: 'post',
  211. url: url,
  212. headers: {
  213. Authorization: 'Bearer ' + this.token
  214. },
  215. }).then(function (res) {
  216. console.log(res)
  217. if (res.data.code == 200) {
  218. that.delegationInfos = res.data.data.delegationInfos;
  219. that.diId=res.data.data.delegationInfos[0].id;
  220. that.setData = res.data.data.setData;
  221. that.ctId=res.data.data.setData[0].id;
  222. that.user = res.data.data.user;
  223. setTimeout(() => {
  224. that.TaskAssignmenQuery();
  225. }, 500);
  226. console.log(that.setData)
  227. }
  228. })
  229. },
  230. //处理时间
  231. getdate(val){
  232. var date=new Date(val);
  233. var y=date.getFullYear();
  234. var m=date.getMonth()+1<10?'0'+(date.getMonth()+1):date.getMonth()+1;
  235. var d=date.getDate()<10?'0'+date.getDate():date.getDate();
  236. return y+'-'+m+'-'+d
  237. },
  238. //取消全选
  239. CancelselectAll(){
  240. this.checkList=[];
  241. this.uploadingcheckList=[];
  242. },
  243. //全选
  244. selectAll(){
  245. for(let i=0;i<this.protogenesischeckList.length;i++){
  246. this.checkList.push(this.protogenesischeckList[i].teamName)
  247. }
  248. this.acquireid()
  249. },
  250. //团组checkbox值改变
  251. checkListchange(){
  252. this.acquireid();
  253. },
  254. //时间段切换
  255. TimePeriodchange(){
  256. this.TaskAllocationGroupSelect()
  257. },
  258. //获取时间段数组
  259. TaskAllocationGroupSelect() {
  260. var that = this
  261. var url = "/api/Groups/TaskAllocationGroupSelect";
  262. this.$axios({
  263. method: 'post',
  264. url: url,
  265. data: {
  266. portType: 1,
  267. visitBeginDt: that.getdate(that.batch.TimePeriod[0]),
  268. visitEndDt: that.getdate(that.batch.TimePeriod[1]),
  269. },
  270. headers: {
  271. Authorization: 'Bearer '
  272. },
  273. }).then(function (res) {
  274. if (res.data.code == 200) {
  275. that.protogenesischeckList=res.data.data;
  276. } else {
  277. }
  278. })
  279. },
  280. //获取选择团组id
  281. acquireid(){
  282. this.uploadingcheckList=[];
  283. for(let j=0;j<this.checkList.length;j++){
  284. for(let i=0;i<this.protogenesischeckList.length;i++){
  285. if(this.checkList[j]==this.protogenesischeckList[i].teamName){
  286. this.uploadingcheckList.push(this.protogenesischeckList[i].id)
  287. }
  288. }
  289. }
  290. },
  291. batchbtn(){
  292. this.batchVisible=true;
  293. this.batch.TimePeriod=[];
  294. this.batch.person=[];
  295. this.batch.category=[];
  296. this.checkList=[];
  297. this.protogenesischeckList=[];
  298. this.uploadingcheckList=[];
  299. },
  300. //保存api
  301. TaskAllocationBulkAdd() {
  302. if(this.uploadingcheckList.length<1){
  303. this.$message.error('保存失败!未选择团组。');
  304. return
  305. }
  306. var that = this
  307. var url = "/api/Groups/TaskAllocationBulkAdd";
  308. this.$axios({
  309. method: 'post',
  310. url: url,
  311. data: {
  312. userIds: that.batch.person,
  313. permissionTypeIds: that.batch.category,
  314. groupIds: that.uploadingcheckList,
  315. currUserId: that.userId,
  316. },
  317. headers: {
  318. Authorization: 'Bearer ' + this.token
  319. },
  320. }).then(function (res) {
  321. if (res.data.code == 200) {
  322. that.$message({
  323. message: res.data.msg,
  324. type: 'success'
  325. });
  326. } else {
  327. that.$message.error(res.data.msg);
  328. }
  329. })
  330. },
  331. //保存
  332. submitForm(batch) {
  333. this.$refs[batch].validate((valid) => {
  334. if (valid) {
  335. this.TaskAllocationBulkAdd()
  336. } else {
  337. console.log('error submit!!');
  338. return false;
  339. }
  340. });
  341. },
  342. TaskAssignmenQuery() {
  343. var that = this
  344. var url = "/api/Groups/TaskAssignmenQuery";
  345. this.$axios({
  346. method: 'post',
  347. url: url,
  348. data: {
  349. diId: that.diId,
  350. ctId: that.ctId,
  351. },
  352. headers: {
  353. Authorization: 'Bearer ' + this.token
  354. },
  355. }).then(function (res) {
  356. if (res.data.code == 200) {
  357. that.userStr = res.data.data.userStr
  358. that.TaskAssignment = res.data.data.taskAssignment
  359. that.DelegationInfo = res.data.data.delegationInfo
  360. that.fullscreenLoading=false;
  361. } else {
  362. that.userStr = [];
  363. that.TaskAssignment = {};
  364. that.DelegationInfo = {}
  365. that.fullscreenLoading=false;
  366. }
  367. })
  368. },
  369. btn() {
  370. var id = 0
  371. var that = this;
  372. if (that.TaskAssignment.id != undefined) {
  373. id = that.TaskAssignment.id;
  374. }
  375. var url = "/api/Groups/GetTaskAssignmenOp";
  376. this.$axios({
  377. method: 'post',
  378. url: url,
  379. data: {
  380. diId: that.diId,
  381. ctId: that.ctId,
  382. uIdStr: that.userStr,
  383. isEnable: 1,
  384. createUserId: that.userId,
  385. remark: ""
  386. },
  387. headers: {
  388. Authorization: 'Bearer ' + that.token
  389. },
  390. }).then(function (res) {
  391. if (res.data.code == 200) {
  392. that.$message({
  393. message: '保存成功!',
  394. type: 'success'
  395. });
  396. } else {
  397. that.$message.error('保存失败!' + res.data.msg);
  398. }
  399. })
  400. },
  401. diidChange() {
  402. this.userStr = [];
  403. this.TaskAssignmenQuery()
  404. console.log(this.userStr)
  405. },
  406. sdIdChange() {
  407. this.TaskAssignmenQuery()
  408. console.log(this.userStr)
  409. },
  410. check(id) {
  411. var index = this.userStr.indexOf(id)
  412. if (index == -1) {
  413. this.userStr.push(id)
  414. } else {
  415. this.userStr = this.userStr.filter((x) => x !== id)
  416. }
  417. }
  418. },
  419. filters:{
  420. filter_city(value){
  421. if(value){
  422. return value.replaceAll('|','、')
  423. }
  424. },
  425. filter_time(value){
  426. if(value){
  427. return value.split(" ")[0]
  428. }
  429. }
  430. },
  431. mounted() {
  432. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  433. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  434. this.GetTaskAssignmen();
  435. }
  436. }
  437. </script>
  438. <style>
  439. .communal-list {
  440. background-color: #fff;
  441. padding: 10px;
  442. box-shadow: 0 0 5px #0005;
  443. border-radius: 10px;
  444. min-height: 820px;
  445. }
  446. .communal-title {
  447. display: flex;
  448. font-size: 17px;
  449. font-weight: 600;
  450. color: #555;
  451. margin-bottom: 15px;
  452. justify-content: space-between;
  453. align-items: center;
  454. }
  455. .communal-box {
  456. display: flex;
  457. }
  458. .communal-box>button {
  459. margin-left: 10px;
  460. padding: 8px 20px;
  461. }
  462. .tzinif-info {
  463. display: flex;
  464. margin-top: 10px;
  465. }
  466. .tzinif-info-li {
  467. margin-right: 30px;
  468. }
  469. .tzinif-info-li label {
  470. color: #606266;
  471. font-size: 15px;
  472. font-weight: 600;
  473. }
  474. .tzinif-info-li span {
  475. color: #606266;
  476. font-size: 14px;
  477. }
  478. .konzh .el-form-item{
  479. margin-bottom: 0;
  480. }
  481. .batchbox{
  482. display: flex;
  483. justify-content: space-between;
  484. }
  485. .checkbox-box{
  486. padding: 10px;
  487. border: 1px solid #DCDFE6 ;
  488. height: 360px;
  489. overflow-y: auto;
  490. }
  491. .batch{
  492. text-align: right;
  493. margin-bottom: 10px;
  494. }
  495. .group-box{
  496. display: flex;
  497. flex-wrap: wrap;
  498. }
  499. </style>