From 9ee7d3bd9c58a204b1efe38e6be61155bbb15c16 Mon Sep 17 00:00:00 2001 From: chr <chr@chr.com> Date: 星期三, 21 八月 2024 19:16:22 +0800 Subject: [PATCH] Merge branch 'master' of http://10.10.28.13:8080/r/PDM/PdmSwPlugin2 --- PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs | 148 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 127 insertions(+), 21 deletions(-) diff --git a/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs b/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs index 3500116..1b6b817 100644 --- a/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs +++ b/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs @@ -1,7 +1,9 @@ 锘縰sing log4net; +using PdmSwPlugin.Commmon.Control; using PdmSwPlugin.Commmon.Util.UI; using PdmSwPlugin.Common; using PdmSwPlugin.Common.Entity.DrawAudit; +using PdmSwPlugin.Common.Entity.Pdm; using PdmSwPlugin.Common.Interface; using PdmSwPlugin.Common.Setting; using PdmSwPlugin.Common.Util; @@ -62,8 +64,36 @@ public ObservableCollection<DrawAudit> dataSource { get => _dataSource; - set => RaiseAndSetIfChanged(ref _dataSource, value); + set + { + RaiseAndSetIfChanged(ref _dataSource, value); + if (value == null) + { + StatusBarText = $"鍏� 0 鏉�"; + } + else + { + StatusBarText = $"鍏� {value.Count} 鏉�"; + } + RefreshSelectedCount(); + } } + + private string _SelectBomText = "宸查�変腑 0 鏉�"; + public string SelectBomText + { + get => _SelectBomText; + set => RaiseAndSetIfChanged(ref _SelectBomText, value); + } + + private string _StatusBarText = "鍏� 0 鏉�"; + + public string StatusBarText + { + get { return _StatusBarText; } + set => RaiseAndSetIfChanged(ref _StatusBarText, value); + } + public DrawApproveControl() : this(null) @@ -98,7 +128,32 @@ { data.selected = cb.IsChecked.Value; } + int count = cb.IsChecked.Value ? (dataSource == null ? 0 : dataSource.Count) : 0; + SelectBomText = $"宸查�変腑 {count} 鏉�"; } + + private void RefreshSelectedCount() + { + if (dataSource == null || dataSource.Count <= 0) + { + SelectBomText = "宸查�変腑 0 鏉�"; + return; + } + int count = dataSource.Where(e => e.selected).Count(); + SelectBomText = $"宸查�変腑 {count} 鏉�"; + } + + /// <summary> + /// 鍗曚釜鐐归�変簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void SingleCheckBox_Event(object sender, RoutedEventArgs e) + { + RefreshSelectedCount(); + } + + private void Button_Click(object sender, RoutedEventArgs e) { @@ -205,39 +260,34 @@ { Button btn = sender as Button; DrawAudit da = btn.DataContext as DrawAudit; - string fileName = Path.GetFileName(da.d2RelativePath); - if (string.IsNullOrEmpty(fileName)) + string filePath = GetRealFilePath(da.d2RelativePath); + if (!File.Exists(filePath)) { - this.Error("鏃犳晥鏂囦欢鍚�"); + this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板伐绋嬪浘鏂囦欢锛岃矾寰�:{filePath}"); return; } - fileName = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); - if (!File.Exists(fileName)) - { - this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板伐绋嬪浘鏂囦欢锛岃矾寰�:{fileName}"); - return; - } - OpenDocMayError(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, + OpenDocMayError(filePath, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, ""); + } + + private string GetRealFilePath(string dbPath) + { + string fileName = Path.GetFileName(dbPath); + string filePath = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); + return filePath; } private void OpenDoc_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; DrawAudit da = btn.DataContext as DrawAudit; - string fileName = Path.GetFileName(da.d3RelativePath); - if (string.IsNullOrEmpty(fileName)) + string filePath = GetRealFilePath(da.d3RelativePath); + if (!File.Exists(filePath)) { - this.Error("鏃犳晥鏂囦欢鍚�"); + this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板浘绾告枃浠讹紝璺緞:{filePath}"); return; } - fileName = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); - if (!File.Exists(fileName)) - { - this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板伐绋嬪浘鏂囦欢锛岃矾寰�:{fileName}"); - return; - } - OpenDocMayError(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, + OpenDocMayError(filePath, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, ""); } @@ -293,6 +343,23 @@ { try { + string filePath = GetRealFilePath(da.d3RelativePath); + if (!File.Exists(filePath)) + { + this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板浘绾告枃浠讹紝璺緞:{filePath}"); + return; + } + + double[] massData = SwDMUtil.GetMassProperty(filePath, out string errMsg); + if (massData == null) + { + this.Error($"鑾峰彇鍥剧焊涓�鑷存�ф暟鎹け璐ワ紒{errMsg}"); + return; + } + da.fileName = Path.GetFileName(filePath); + da.volume = NumberUtil.HandleMass(massData[3]); + da.surfaceArea = NumberUtil.HandleMass(massData[4]); + da.mass = NumberUtil.HandleMass(massData[5]); da.pass = true; Result<object> res = Client.PostSyncAction<object>(da, "drawAudit/complete"); object obj = res.HandleResult(); @@ -305,6 +372,7 @@ catch (Exception ex) { Logger.Error("Draw complete failed.", ex); + this.Error($"瀹℃牳澶辫触锛亄ex.Message}"); } finally { @@ -345,5 +413,43 @@ dataSource = new ObservableCollection<DrawAudit>(RefreshList()); }); } + + private void TextBlock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + // 妫�鏌ユ槸鍚︽槸鍙屽嚮 + if (e.ClickCount == 2) + { + TextBlock textBlock = sender as TextBlock; + DrawAudit data = textBlock.DataContext as DrawAudit; + MaskAdorner.ShowMask(content, "璇锋眰涓紝璇风◢鍚�..."); + Task.Run(() => + { + try + { + Result<List<DrawAuditHis>> res = Client.GetSyncAction<List<DrawAuditHis>>("drawAudit/listTaskHis", new DrawAudit + { + id = data.id + }); + var datas = res.HandleResult(); + Dispatcher.Invoke(() => + { + //DrawAuditHisWindow window = new DrawAuditHisWindow(this, $"銆恵bom.partModel}銆戝鏍歌鎯�", datas); + RichHisWindow window = new RichHisWindow(this, $"銆恵data.materialCode}銆戝鏍歌鎯�", datas); + + window.ShowDialog(); + }); + } + catch (Exception ex) + { + Logger.Error("Get draw audit history failed.", ex); + this.Error($"鑾峰彇瀹℃牳鍘嗗彶澶辫触锛亄ex.Message}"); + } + finally + { + MaskAdorner.HideMask(content); + } + }); + } + } } } -- Gitblit v1.9.1