Explorar o código

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

liqk %!s(int64=4) %!d(string=hai) anos
pai
achega
017450ed44

+ 1 - 1
TEAMModelFunction/ActivityHttpTrigger.cs

@@ -411,7 +411,7 @@ namespace TEAMModelFunction
             }
             List<ItemCond> itemConds = new List<ItemCond>();
             items.GroupBy(x => x.periodId).ToList().ForEach( x=> {
-                ItemCond cond = new ItemCond() { id=x.Key,code=$"ItemCond-hbcn" };
+                ItemCond cond = new ItemCond() { id=x.Key,code=$"ItemCond-hbcn" ,pk= "ItemCond" ,ttl=-1};
                 x.ToList().ForEach(y => {
                    ItemService.CountItemCond(y, null, cond);
                 });

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Syllabus.cs

@@ -20,7 +20,7 @@ namespace TEAMModelOS.SDK.Models
         [Required(ErrorMessage = "{0} 必须填写")]
         public List<Tnode> children { get; set; }
         public string volumeId { get; set; }
-        public List<SyllabusAuth> auth { get; set; }
+        public List<SyllabusAuth> auth { get; set; } = new List<SyllabusAuth>();
         public string scope { get; set; }
 }
 

+ 1 - 0
TEAMModelOS/ClientApp/package.json

@@ -33,6 +33,7 @@
 		"firebase": "^7.19.0",
 		"firestore": "^1.1.6",
 		"html2canvas": "^1.0.0-rc.7",
+		"html2pdf.js": "^0.9.3",
 		"imports-loader": "^0.8.0",
 		"increase-memory-limit": "^1.0.7",
 		"js-sha1": "^0.6.0",

+ 3 - 0
TEAMModelOS/ClientApp/src/api/syllabus.js

@@ -19,6 +19,9 @@ export default {
 	DeleteTree:function(data) {
 	    return post('/common/syllabus/delete', data)
 	},
+	ShareTree:function(data) {
+	    return post('/teacher/share/to', data)
+	},
 	// 查找知识块数量
 	FindBlockCount: function (data) {
 		return post('/knowledges/find-count', data)

+ 19 - 0
TEAMModelOS/ClientApp/src/common/BaseNotification.vue

@@ -5,6 +5,10 @@
 				<Icon type="md-notifications" />
 			</Badge>
 			<div slot="content" class="notice-wrap">
+				<div v-if="!msgArr.length" class="notice-empty">
+					<Icon type="md-text" />
+					暂无通知
+				</div>
 				<div class="notice-item" v-for="(item,index) in msgArr" :key="index" @click="doClickMsg(item)">
 					<p class="item-name">{{ getMsgType(item) }}</p>
 					<p class="item-content">{{ getMsgContent(item) }}</p>
@@ -123,6 +127,21 @@
 			box-shadow: none;
 			padding: 0;
 		}
+		
+		.notice-empty{
+			display: flex;
+			flex-direction: column;
+			justify-content: center;
+			align-items: center;
+			margin: 20px 0;
+			color: #b3b3b3;
+			
+			.ivu-icon{
+				font-size: 44px;
+				margin-bottom: 20px;
+				color: #6c6c6c;
+			}
+		}
 
 		.notice-wrap {
 			display: flex;

+ 4 - 1
TEAMModelOS/ClientApp/src/components/syllabus/DragTree.vue

@@ -297,7 +297,10 @@
 			treeData: {
 				handler: function(n, o) {
 					// 以下为拼接树形数据以及册别数据
-					this.treeDatas = n.map(i => i.trees[0])
+					this.treeDatas = n.map(i => {
+						i.trees[0].auth = i.auth
+						return i.trees[0]
+					})
 					this.getAllChild(this.treeDatas)
 					this.$nextTick().then(() => {
 						const firstNode = document.querySelector('.el-tree-node')

+ 65 - 3
TEAMModelOS/ClientApp/src/components/syllabus/InviteTeacher.vue

@@ -18,7 +18,7 @@
 				</template>
 				<template slot-scope="{ row }" slot="action">
 					<div style="display: flex;align-items: center;">
-						<i-switch true-color="#13ce66"></i-switch>
+						<i-switch true-color="#13ce66" :value="hasAuth(row.id)" :before-change="handleBeforeChange"  @on-change="onSwitchChange(row,$event)"></i-switch>
 					</div>
 				</template>
 			</Table>
@@ -34,6 +34,7 @@
 					</div>
 					<p v-if="!curTeacher && hasSearchResult" class="search-none">暂未查询到相关结果</p>
 					<p v-if="hasSearchResult" class="re-search" @click="onReSearch">重新搜索</p>
+					<Button type="success" v-if="hasSearchResult"  @click="doShare">确认分享</Button>
 				</div>
 			</div>
 		</div>
@@ -112,7 +113,7 @@
 						if (res.code == 0) {
 							this.$Message.error('無法取得使用者資料')
 						} else {
-							this.teacherList = this.$store.state.user.schoolUserList.filter(i => i.status === 'join')
+							this.teacherList = this.$store.state.user.schoolUserList.filter(i => i.status === 'join' && i.id !== this.$store.state.userInfo.TEAMModelId)
 							this.originList = JSON.parse(JSON.stringify(this.teacherList))
 						}
 					},
@@ -151,11 +152,72 @@
 				this.searchIdVal = ''
 				this.curTeacher = null
 				this.hasSearchResult = false
+			},
+			/* 修改共编权限前回调 */
+			handleBeforeChange(){
+				return new Promise((resolve) => {
+					this.$Modal.confirm({
+						title: '修改确认',
+						content: '确认修改当前用户的共编状态?',
+						onOk: () => {
+							resolve();
+						}
+					});
+				});
+			},
+			/* 修改共编权限 */
+			onSwitchChange(val,e){
+				let curVolume = this.$parent.$parent.curVolume
+				this.$api.syllabus.ShareTree({
+					"school": curVolume.school,
+					"scope": curVolume.scope,
+					"tmdInfo": [
+						{
+							"tmdid": val.id,
+							"tmdname": val.name
+						}
+					],
+					"coedit": true,
+					"share": false,
+					"issuer": this.$store.state.userInfo.TEAMModelId,
+					"opt": e ? 'add' : 'del',
+					"syllabusId": this.nodeInfo.id,
+					"syllabusName": this.nodeInfo.title,
+					"volumeId": curVolume.id,
+					"volumeName": curVolume.name
+				}).then(res => {
+					if(res.code === 200){
+						this.$Message.success('操作成功!')
+					}
+				}).catch(err => {
+					this.$Message.error(err)
+				})
+			},
+			/* 分享课纲操作 */
+			doShare(){
+				console.log(this.curTeacher);
 			}
 		},
 		mounted() {
 			this.isSchool && this.getAllTeacher()
 		},
+		computed:{
+			hasAuth(){
+				return id => {
+					if(!this.nodeInfo.auth){
+						return false
+					}else{
+						let matchItem = this.nodeInfo.auth.filter(i => i.tmdid === id)
+						console.log(matchItem)
+						if(matchItem.length && matchItem[0].coedit){
+							return true
+						}else{
+							return false
+						}
+					}
+				}
+			}
+		},
 		watch: {
 			node: {
 				handler(n, o) {
@@ -211,7 +273,7 @@
 			}
 			
 			.id-search{
-				height: 400px;
+				min-height: 400px;
 				width: 100%;
 				display: flex;
 				flex-direction: column;

+ 2 - 2
TEAMModelOS/ClientApp/src/utils/dom_to_image.js

@@ -155,7 +155,7 @@
             .then(util.makeImage)
             .then(util.delay(100))
             .then(function (image) {
-                console.log(image)
+                // console.log(image)
                 var canvas = newCanvas(domNode);
                 canvas.getContext('2d').drawImage(image, 0, 0);
                 return canvas;
@@ -674,7 +674,7 @@
                         return rule.type === CSSRule.FONT_FACE_RULE;
                     })
                     .filter(function (rule) {
-                        console.log(rule.style.getPropertyValue('href'))
+                        // console.log(rule.style.getPropertyValue('href'))
                         return inliner.shouldProcess(rule.style.getPropertyValue('href'));
                     });
             }

+ 4 - 3
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -193,12 +193,12 @@
 		</Modal>
 		
 		<!-- 选择共编、分享弹窗 -->
-		<Modal v-model="isInviteModal" width="750" class="tree-modal add-volume-modal choose-content-modal">
+		<Modal v-model="isInviteModal" width="750" footer-hide class="tree-modal add-volume-modal choose-content-modal">
 			<div class="modal-header" slot="header">
 				选择{{ isSchool ? '共编' : '分享' }}教师
 			</div>
-			<InviteTeacher :node="curShareNode" ref="inviteRef"></InviteTeacher>
-			<Button slot="footer" @click="doInviteTeacher" style="margin-bottom: 20px;" class="modal-btn">确认</Button>
+			<InviteTeacher :node="curShareNode" ref="inviteRef" v-if="isInviteModal"></InviteTeacher>
+			<!-- <Button slot="footer" @click="doInviteTeacher" style="margin-bottom: 20px;" class="modal-btn">确认</Button> -->
 		</Modal>
 
 		<!-- 预览试题试卷弹窗 -->
@@ -852,6 +852,7 @@
 					}
 					if (this.isEditVolume && this.curVolume) {
 						addVolumeParams.id = this.curVolume.id
+						addVolumeParams.name = this.curVolume.name
 						addVolumeParams.syllabusIds = this.allChapterIds || []
 					}
 					// 发送新增或者编辑册别请求

+ 57 - 5
TEAMModelOS/Controllers/Item/ItemController.cs

@@ -48,7 +48,21 @@ namespace TEAMModelOS.Controllers
             _serviceBus = serviceBus;
             _configuration = configuration;
         }
-
+        [ProducesDefaultResponseType]
+        [HttpPost("cond-count")]
+        public async Task<IActionResult> CondCount(JsonElement request) {
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+                if (!request.TryGetProperty("periodId", out JsonElement periodId)) return BadRequest();
+                if (!request.TryGetProperty("schoolCode", out JsonElement schoolCode)) return BadRequest();
+                ItemCond itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>($"{periodId}", new PartitionKey($"ItemCond-{schoolCode}"));
+                return Ok(new { itemCond });
+            } catch (Exception ex) {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},item/cond-count()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
         [ProducesDefaultResponseType]
         [HttpPost("upsert")]
         public async Task<IActionResult> Upsert(JsonElement request)
@@ -97,6 +111,16 @@ namespace TEAMModelOS.Controllers
                         {
                           // itemInfo.periodId
                             itemInfo = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            ItemCond itemCond = null;
+                            try {
+
+                                itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
+                            } catch (Exception  ex) {
+                                itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, conds = new Dictionary<string, List<CondCount>>() };
+
+                            };
+                            ItemService.CountItemCond(itemInfo, null, itemCond);
+                            await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
                         }
                     }
                 }
@@ -108,7 +132,6 @@ namespace TEAMModelOS.Controllers
                         if (!itemInfo.code.Contains("Item"))
                         {
                             itemInfo.code = "Item-" + itemInfo.code;
-                            // itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
                         }
                         itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
 
@@ -118,10 +141,23 @@ namespace TEAMModelOS.Controllers
                         if (!itemInfo.code.Contains("Item"))
                         {
                             itemInfo.code = "Item-" + itemInfo.code;
-                            //itemInfo = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
                         }
+                        ItemInfo olditemInfo = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemInfo>( itemInfo.id, new PartitionKey($"{itemInfo.code}"));
                         itemInfo = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
+                        //更新题目数量
+                        ItemCond itemCond = null;
+                        try
+                        {
 
+                            itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
+                        }
+                        catch (Exception ex)
+                        {
+                            itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, conds = new Dictionary<string, List<CondCount>>() };
+
+                        };
+                        ItemService.CountItemCond(itemInfo, olditemInfo, itemCond);
+                        await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
 
                     }
                 }
@@ -246,7 +282,22 @@ namespace TEAMModelOS.Controllers
                 await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
                 if (scope.ToString().Equals("school"))
                 {
+                    ItemInfo itemInfo = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemInfo>(id.ToString(), new PartitionKey($"{code}"));
                     var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
+                    //更新题目数量
+                    ItemCond itemCond = null;
+                    try
+                    {
+
+                        itemCond = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
+                    }
+                    catch (Exception ex)
+                    {
+                        itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, conds = new Dictionary<string, List<CondCount>>() };
+
+                    };
+                    ItemService.CountItemCond(null, itemInfo, itemCond);
+                    await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
                     return Ok(new { code = response.Status });
                 }
                 else
@@ -254,11 +305,12 @@ namespace TEAMModelOS.Controllers
                     var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
                     return Ok(new { code = response.Status });
                 }
-
+              
+               
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},item/FindSummary()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},item/delete()\n{e.Message},{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
 

+ 3 - 3
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -85,7 +85,7 @@ namespace TEAMModelOS.Controllers
                             syllabusAuths.ForEach(x => {
                                 syllabusD.auth.Remove(x);
                             });
-                            await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabusD, request.volumeId, new PartitionKey($"Syllabus-{request.volumeId}"));
+                            await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabusD, request.syllabusId, new PartitionKey($"Syllabus-{request.volumeId}"));
                             request.tmdInfo.ForEach(async x => {
                                 await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>(request.syllabusId, new PartitionKey($"Share-{x.tmdid}"));
                             });
@@ -96,7 +96,7 @@ namespace TEAMModelOS.Controllers
                     {
                         (Syllabus syllabus, List<Share> shares) = DoAuth(request, syllabusD);
                         shares.ForEach(async x=> {
-                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"Share-{x.code}"));
+                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
                         });
                        
                         await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.volumeId}"));
@@ -129,7 +129,7 @@ namespace TEAMModelOS.Controllers
                     {
                         (Syllabus vlm, List<Share> shares) = DoAuth(request, syllabusD);
                         shares.ForEach(async x => {
-                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"Share-{x.code}"));
+                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
                         });
                         await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Syllabus>(syllabusD, new PartitionKey($"Syllabus-{request.volumeId}"));
                     }

+ 2 - 1
TEAMModelOS/Controllers/Syllabus/SyllabusController.cs

@@ -65,9 +65,10 @@ namespace TEAMModelOS.Controllers
         [HttpPost("upsert-tree")]
         public async Task<IActionResult> SaveOrUpdateAsTree(List<SyllabusTreeNode> request)
         {
+            long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
             foreach (SyllabusTreeNode syllabusTree in request) {
                 List<Tnode> nodes = new List<Tnode>();
-                SyllabusService.TreeToList(syllabusTree.trees, nodes);
+                SyllabusService.TreeToList(syllabusTree.trees, nodes, now);
                 if (!string.IsNullOrEmpty(syllabusTree.id))
                 {
                     Syllabus syllabus = null;

+ 3 - 3
TEAMModelOS/Services/Common/SyllabusService.cs

@@ -40,7 +40,7 @@ namespace TEAMModelOS.Services.Common
         }
 
 
-        public static List<Tnode> TreeToList(List<SyllabusTree> trees, List<Tnode> nodes)
+        public static List<Tnode> TreeToList(List<SyllabusTree> trees, List<Tnode> nodes,long now)
         {
             int index = 0;
             foreach (SyllabusTree tr in trees)
@@ -65,7 +65,7 @@ namespace TEAMModelOS.Services.Common
                     rnodes = x.rnodes,
                     cids= cids,
                     creatorId=x.creatorId,
-                    updateTime=x.updateTime
+                    updateTime= now
                 };
                 list.Add(node);
             });
@@ -75,7 +75,7 @@ namespace TEAMModelOS.Services.Common
             {
                 if (null != tree.children && tree.children.Count > 0)
                 {
-                    TreeToList(tree.children, nodes);
+                    TreeToList(tree.children, nodes,now);
                 }
             }
             return nodes;