tanghaolin
2022-08-31 244c4241427b9f3316f06f1e0ae2ee571edc1a23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!--  -->
<template>
  <div class="modelLibraryIndex_box" v-myTitle="{ title: $t('selectPage.model.TR') }">
    <!-- 头部导航栏 -->
    <van-nav-bar>
      <template #left>
        <div style="display: flex; align-items: center" @click="pageBack">
          <van-icon name="arrow-left" size="18" />
          <span></span>
        </div>
      </template>
      <template #title>
        <label style="color: #ffffff">{{ $t('selectPage.model.TR') }}</label>
      </template>
      <template #right> </template>
    </van-nav-bar>
    <div class="modelLibraryIndex_main">
      <div style="display: flex">
        <vcolorpicker v-model="model_background_color"></vcolorpicker>
        <van-field
          style="flex: 1"
          readonly
          clickable
          :label="$t('selectPage.model.TR') + ':'"
          :value="modelValue"
          @click="showPicker = true"
        />
      </div>
 
      <van-popup
        v-model="showPicker"
        @closed="getSizeValue"
        duration="0.2"
        round
        position="bottom"
      >
        <van-picker
          show-toolbar
          :columns="pumpList"
          @cancel="showPicker = false"
          @confirm="onConfirm"
        >
          <template #option="item">
            <span>{{ item.Text }}</span>
          </template>
        </van-picker>
      </van-popup>
      <div style="width: 100%; height: calc(100% - 45px); position: relative">
        <model3D ref="model3dCtrl"></model3D>
      </div>
    </div>
  </div>
</template>
 
<script>
import model3D from "@/components/model3DContainer.vue";
import vcolorpicker from "./vcolorpicker.vue";
export default {
  name: "Model3DSizeIndex",
  components: {
    model3D,
    vcolorpicker,
  },
  data() {
    return {
      pumpList: [],
      showPicker: false,
      modelValue: "",
      topTitle: "型号",
      CorpName: "型号",
      currentFilePath: "",
      currentPumpInfo: null, //当前泵信息
      m_currentLawNode: "", //当前加载模型节点
      model_background_color: "#cc",
      isload: false,
      isShowColorPicker: false,
    };
  },
  created() {},
  mounted() {
    var query_data = this.$route.query;
 
    this.currentFilePath= query_data.FilePath;
    this.initPumpList(query_data);
  },
  computed: {},
  watch: {
    model_background_color(val) {
      this.isload && this.$refs.model3dCtrl.setBackgroundColor(val);
    },
  },
  methods: {
    //颜色选择确认
    confirmColor() {
      this.isShowColorPicker = false;
      let val = this.model_background_color;
      this.isload && this.$refs.model3dCtrl.setBackgroundColor(val.hex);
    },
    initModel3D(url) {
      if (!url) return;
      //加载三位模型
      let _this = this;
      _this.isload = false;
      //console.log(url);   
      this.$refs.model3dCtrl.loadModel(url, true, function (val) {
        _this.isload = true;
        _this.pumpList.length > 0 && _this.getSizeValue();
      });
    },
    initPumpList(lawNode) {
      //  console.log(lawNode,111)
      if (lawNode == null) return;
 
      this.m_currentLawNode = lawNode;
      var SeriesID = lawNode.SeriesID;
      var LawID = lawNode.LawID;
 
      if (SeriesID == null || SeriesID == 0) return;
      if (LawID == null || LawID == 0) return;
      let _this = this;
      let url =
        globalConfig.WebApiUrl.MainUrl +
        "v1/ModelLibrary/GetFileNameList?SeriesID=" +
        lawNode.SeriesID +
        "&LawID=" +
        lawNode.LawID +
        "&Lang=0";
 
      this.$axios({
        url: url,
        method: "get",
      }).then(function (res) {
        let resData = res.data;
        //  console.log(resData, 116);
          
        if (resData.Code != 0) {
          _this.$toast(resData.Message);
          resData.Data = [];
        }
        let pumpList = resData.Data;
 
        _this.pumpList = pumpList;
        if (pumpList.length != 0) {
          _this.modelValue = pumpList[0].Text;
          _this.currentPumpInfo = pumpList[0];
          let url = globalConfig.WebApiUrl.FileUrl + _this.currentFilePath;
          //console.log(url, 146);
          
          setTimeout(() => {
            _this.initModel3D(url);
          }, 200);
        }else{
            _this.$toast("无法获取泵列表");
      return;    
        }
      });
    },
    downloadModel3D() {
      this.$toast("如需下载模型,请联系义维科技");
      return;
      let FilePath = this.currentPumpInfo.FilePath;
      let href = globalConfig.WebApiUrl.FileUrl + FilePath;
      let a = document.createElement("a"); // 生成一个a元素
      let event = new MouseEvent("click"); // 创建一个单击事件
      a.href = href; // 将生成的URL设置为a.href属性
      a.dispatchEvent(event); // 触发a的单击事件
    },
    onConfirm(value, key) {
      this.showPicker = false;
 
      this.modelValue = value.Text;
      this.currentPumpInfo = value;
      let url = globalConfig.WebApiUrl.FileUrl + this.currentFilePath;
    },
    getSizeValue() {
      let _this = this;
      let lawNode = this.m_currentLawNode;
      // 
      // console.log(lawNode,140);
      // return;
      if (lawNode == null) return;
 
      if (lawNode.IsHaveDim == "false") {
        _this.$refs.model3dCtrl.setDimDisplay(false);
        return;
      }
      let SeriesID = lawNode.SeriesID;
      let LawID = lawNode.LawID;
      let dispPumpName = this.modelValue;
      let fileName = dispPumpName.replace("/", "-");
 
      if (SeriesID == null || SeriesID == 0) return;
      if (LawID == null || LawID == 0) return;
      let url =
        globalConfig.WebApiUrl.MainUrl +
        "v1/ModelLibrary/GetProductDimList?SeriesID=" +
        SeriesID +
        "&LawID=" +
        LawID +
        "&FileName=" +
        fileName +
        "&Lang=0";
      this.$axios({
        url: url,
        method: "get",
      }).then(function (res) {
        let resData = res.data;
        // console.log(resData,300)
        if (resData.Code != 0) {
          //_this.$toast("ssss"+resData.Message);
          _this.$refs.model3dCtrl.setDimDisplay(false);
          return;
        }
        _this.$refs.model3dCtrl.setDimDisplay(true);
        _this.$refs.model3dCtrl.updateSizeValue(resData.Data);
      });
    },
    //返回上一页
    pageBack() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang="scss">
.modelLibraryIndex_box {
  width: 100%;
  height: 100vh;
  .modelLibraryIndex_main {
    width: 100%;
    height: calc(100% - 46px);
    background-color: #fafafa;
    overflow: auto;
    margin-top: 1px;
    .van-cell__title,
    .van-cell__value {
      display: flex;
      align-items: flex-start;
      flex-direction: column;
      color: #36489e !important;
    }
    .van-index-anchor {
      text-align: left;
      font-weight: 600;
    }
  }
}
</style>