attr_select.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <template>
  2. <div id="attr-select">
  3. <!--选中-->
  4. <div class="attr-select" v-if="type==='baseLine'">
  5. <span class="grid-title">外观</span>
  6. <div class="row">
  7. <div class="row-tit">线宽</div>
  8. <div class="grid-content">
  9. <a-input-number
  10. v-model="lineWidth"
  11. :min="1"
  12. @change="changeLineWidth"
  13. style="width: 168px"
  14. />
  15. </div>
  16. <div class="color-choice">
  17. <swatches v-model="borderColor" popover-x="left" @close="changeBorderColor" />
  18. </div>
  19. </div>
  20. <div class="row">
  21. <div class="row-tit">线型</div>
  22. <a-select
  23. style="width: 208px"
  24. v-model="borderStyle"
  25. :default-value="borderLineOption[0].id"
  26. @change="changeBorder"
  27. >
  28. <a-select-option
  29. v-for="item in borderLineOption"
  30. :key="item.id"
  31. :label="item.src"
  32. :value="item.id"
  33. >
  34. <img :src="item.src" alt />
  35. </a-select-option>
  36. </a-select>
  37. </div>
  38. </div>
  39. <!--文字内容-->
  40. <div class="attr-select" v-if="type==='baseText'">
  41. <span class="grid-title">文字内容</span>
  42. <div class="grid-content">
  43. <a-textarea
  44. placeholder="请在此处输入文字!"
  45. v-model="textMsg"
  46. allow-clear
  47. @change="changeTextArea"
  48. :rows="4"
  49. />
  50. </div>
  51. <span class="grid-title">外观</span>
  52. <div class="row">
  53. <div class="row-tit">字号</div>
  54. <div class="grid-content">
  55. <a-input-number v-model="fontSize" :min="1" @change="changeFont" style="width: 168px" />
  56. </div>
  57. <div class="color-choice">
  58. <swatches v-model="fontColor" popover-x="left" @close="changeFontColor" />
  59. </div>
  60. </div>
  61. <div class="row">
  62. <div class="row-tit">背景色</div>
  63. <div class="color-choice">
  64. <swatches v-model="backColor" :swatches="swatches" popover-x="left" @close="changebackColor" />
  65. </div>
  66. </div>
  67. </div>
  68. <!--图片-->
  69. <div class="attr-select" v-if="type=='baseImage'">
  70. <span class="grid-title">文字内容</span>
  71. <section class="grid">
  72. <div class="grid-content">
  73. <a-upload-dragger
  74. name="file"
  75. :customRequest="customRequest"
  76. :showUploadList="false"
  77. action="https://jsonplaceholder.typicode.com/posts/"
  78. @change="changeImage"
  79. >
  80. <p class="icon-image">
  81. <a-icon type="cloud-upload" />
  82. </p>
  83. <p class="ant-upload-text">将图片拖动到这里替换</p>
  84. <p class="ant-upload-hint">本地上传</p>
  85. </a-upload-dragger>
  86. </div>
  87. </section>
  88. <span class="grid-title">外观</span>
  89. <div class="row">
  90. <div class="row-tit">边框</div>
  91. <div class="grid-content">
  92. <a-input-number
  93. v-model="lineWidth"
  94. :min="1"
  95. @change="changeLineWidth"
  96. style="width: 168px"
  97. />
  98. </div>
  99. <div class="color-choice">
  100. <swatches v-model="color" popover-x="left" />
  101. </div>
  102. </div>
  103. </div>
  104. <!--针对“设备/位置/管线/分区”属性示例-->
  105. <div class="attr-select" v-show="type =='Image'|| type == 'Line' || type == 'Zone'">
  106. <div v-if="type =='Image'|| type == 'Line'">
  107. <div class="row">
  108. <div class="row-tit">名称显示</div>
  109. <a-button type="link" class="edit-option-btn" @click="OpenEditStatus">{{editStatus[type]}}</a-button>
  110. </div>
  111. <div class="row">
  112. <a-input v-model="lengedName" @change="changeLengedName" />
  113. </div>
  114. <div class="row">
  115. <div class="row-tit">字号</div>
  116. <div class="grid-content">
  117. <a-input-number v-model="fontSize" :min="1" @change="changeFont" style="width: 168px" />
  118. </div>
  119. <div class="color-choice">
  120. <swatches v-model="fontColor" @close="changeFontColor" popover-x="left" />
  121. </div>
  122. </div>
  123. <!-- 当为设备状态时 -->
  124. <div class="row" v-if="type =='Image'">
  125. <div class="row-tit">数量</div>
  126. <div class="grid-content">
  127. <a-input-number
  128. v-model="imageNum"
  129. :min="attrCards.length==imageNum?imageNum:1"
  130. @change="changeImageNum"
  131. style="width: 208px"
  132. />
  133. </div>
  134. </div>
  135. <!-- 当为管道状态时 -->
  136. <div class="row" v-if="type =='Line'">
  137. <div class="row-tit">线宽</div>
  138. <div class="grid-content">
  139. <a-input-number
  140. v-model="lineWidth"
  141. :min="1"
  142. @change="changeLineWidth"
  143. style="width: 208px"
  144. />
  145. </div>
  146. </div>
  147. </div>
  148. <div v-if="type == 'Zone'">
  149. <div v-if="SubType=='FHFQ'">
  150. <!-- 防火分区 -->
  151. <div class="row-tit">颜色</div>
  152. <div class="row">
  153. <swatches @input="changefillColor" :swatches="swatchess" v-model="fillColor" inline></swatches>
  154. </div>
  155. <div class="row">
  156. <div class="row-tit">名称显示</div>
  157. <a-button
  158. type="link"
  159. class="edit-option-btn"
  160. @click="OpenEditStatus"
  161. >{{editStatus[type]}}</a-button>
  162. </div>
  163. <div class="row">
  164. <a-input v-model="lengedName" @change="changeLengedName" />
  165. </div>
  166. <div class="row">
  167. <div class="row-tit">字号</div>
  168. <div class="grid-content">
  169. <a-input-number
  170. v-model="fontSize"
  171. :min="1"
  172. @change="changeFont"
  173. style="width: 168px"
  174. />
  175. </div>
  176. <div class="color-choice">
  177. <swatches v-model="fontColor" @close="changeFontColor" popover-x="left" />
  178. </div>
  179. </div>
  180. </div>
  181. <div v-if="SubType=='SCPZ'">
  182. <!-- 石材铺装 -->
  183. <div class="row">
  184. <div class="row-tit">图例说明</div>
  185. <a-button type="link" class="edit-option-btn" @click="OpenEditStatus">编辑区域</a-button>
  186. </div>
  187. <div class="row">
  188. <a-textarea @change="changeitemExplain" v-model="itemExplain" :auto-size="{ minRows: 4, maxRows: 6 }" />
  189. </div>
  190. <div class="row">
  191. <div class="row-tit">描边</div>
  192. <div class="grid-content">
  193. <a-input-number
  194. v-model="lineWidth"
  195. :min="1"
  196. @change="changeLineWidth"
  197. style="width: 168px"
  198. />
  199. </div>
  200. <div class="color-choice">
  201. <swatches v-model="borderColor" @close="changeBorderColor" popover-x="left" />
  202. </div>
  203. </div>
  204. <div class="row">
  205. <div class="row-tit">填充</div>
  206. <div class="color-choice">
  207. <swatches v-model="fillColor" @close="changefillColor" popover-x="left" />
  208. </div>
  209. </div>
  210. </div>
  211. <div v-if="!SubType">
  212. <!-- 普通分区 -->
  213. <div class="row">
  214. <div class="row-tit">名称显示</div>
  215. <a-button
  216. type="link"
  217. class="edit-option-btn"
  218. @click="OpenEditStatus"
  219. >{{editStatus[type]}}</a-button>
  220. </div>
  221. <div class="row">
  222. <a-input v-model="lengedName" @change="changeLengedName" />
  223. </div>
  224. <div class="row">
  225. <div class="row-tit">字号</div>
  226. <div class="grid-content">
  227. <a-input-number
  228. v-model="fontSize"
  229. :min="1"
  230. @change="changeFont"
  231. style="width: 168px"
  232. />
  233. </div>
  234. <div class="color-choice">
  235. <swatches v-model="fontColor" @close="changeFontColor" popover-x="left" />
  236. </div>
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241. <!--设备/工程信息化ID/工程信息化中的位置类型-->
  242. <div
  243. class="attr-select attr-select-bottom"
  244. v-if="type =='Zone' || type =='Image'||type == 'Line'"
  245. >
  246. <a-spin :spinning="spinning">
  247. <div class="row">
  248. <span>{{type =='Zone'?`工程信息化中的位置类型`:'工程信息化中的设备类型'}}</span>
  249. <a-button type="link" class="edit-option-btn" @click="handleEdit">选择编辑</a-button>
  250. </div>
  251. <div class="grid-content">
  252. <a-card class="attr-card" v-for="(item,index) in attrCards" :key="index">{{item.sbjc ||item.wzjc}}</a-card>
  253. </div>
  254. </a-spin>
  255. </div>
  256. <!-- 快捷操作提示-->
  257. <div style="position: fixed;bottom: 0;width: 280px;" class="key-boards">
  258. <a-collapse :bordered="false" expand-icon-position="right">
  259. <template #expandIcon="props">
  260. <a-icon type="caret-up" :rotate="props.isActive ? 180 : 0" />
  261. </template>
  262. <a-collapse-panel key="1" :style="customStyle">
  263. <template slot="header">
  264. <div style="font-size: 12px;color: #8D9399;">
  265. <a-icon type="exclamation-circle" />
  266. <span style="margin-left: 5px;">键盘操作提示</span>
  267. </div>
  268. </template>
  269. <p
  270. v-for="item in keyboardOperation"
  271. :key="item.value"
  272. style="display: flex;margin-top: 13px;"
  273. >
  274. <span>{{item.value}}</span>
  275. <span class="key-board">{{item.keys}}</span>
  276. <span v-if="item.events" style="margin: 0 5px;">+ <img style="width:13px;height:18px;" src="./../../assets/images/shubiao.png" alt=""></span>
  277. <span> {{item.events}}</span>
  278. </p>
  279. </a-collapse-panel>
  280. </a-collapse>
  281. </div>
  282. <editDialog ref="dialog" :attrCards="attrCards" :typeEdit="type" :getmajorId="getmajorId" :sysNum="imageNum" :key="new Date().getTime()"/>
  283. <!-- <editDialog ref="dialog" :typeEdit="2" :getmajorId="'1001'" :sysNum="5" />-->
  284. </div>
  285. </template>
  286. <script>
  287. import editDialog from "./edit-dialog";
  288. import Swatches from "vue-swatches";
  289. import bus from "@/bus";
  290. import "vue-swatches/dist/vue-swatches.css";
  291. import { SLineStyle } from "@saga-web/graph/lib";
  292. import { uploadImg, queryGlsmsLocation,queryGlsmsAsset } from "@/api/editer.js";
  293. import {getUrlMsg} from '@/components/urlMsg.js'
  294. export default {
  295. name: "attr_select",
  296. props: ["type", "focusItemList"],
  297. components: { editDialog, Swatches },
  298. data() {
  299. return {
  300. precisionList: [{ value: 10 }, { value: 20 }, { value: 30 }],
  301. precision: true,
  302. customStyle:
  303. "background: #fff;overflow: hidden; box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.11);border:0",
  304. keyboardOperation: [
  305. { value: "拖动画布:", keys: "Space", events: "Click" },
  306. { value: "加选对象:", keys: "Ctrl", events: "Press" },
  307. { value: "确认操作:", keys: "Enter" },
  308. { value: "取消对象:", keys: "Enter" }
  309. ],
  310. numberValue: 3,
  311. fontSize: 12, //字体大小
  312. lineWidth: 0,
  313. textMsg: "", //
  314. color: "#1CA085",
  315. fontColor: "#1CA085", //文字颜色
  316. borderColor: "", // 边框颜色 直线,折线,多边形等
  317. backColor: "", //背景色 用于text文字
  318. borderStyle: "solid",
  319. borderLineOption: [
  320. {
  321. id: "solid",
  322. src: require("@/assets/images/1pxline.jpg")
  323. },
  324. {
  325. id: "dashed",
  326. src: require("@/assets/images/dashedLine.jpg")
  327. },
  328. {
  329. id: "dotted",
  330. src: require("@/assets/images/dotLine.jpg")
  331. }
  332. ],
  333. linepxOption: [
  334. {
  335. id: 1,
  336. src: require("@/assets/images/1pxline.jpg")
  337. },
  338. {
  339. id: 2,
  340. src: require("@/assets/images/2pxline.jpg")
  341. },
  342. {
  343. id: 3,
  344. src: require("@/assets/images/3pxline.jpg")
  345. }
  346. ],
  347. editStatus: {
  348. Image: "编辑设备",
  349. Line: "管道编辑",
  350. Zone: "编辑区域"
  351. },
  352. swatchess: ["#69C5FC", "#656EDF", "#58AF6F", "#2D8FAA"],
  353. swatches: [
  354. "#00000000",
  355. "#1FBC9C",
  356. "#1CA085",
  357. "#2ECC70",
  358. "#27AF60",
  359. "#3398DB",
  360. "#2980B9",
  361. "#A463BF",
  362. "#8E43AD",
  363. "#3D556E",
  364. "#222F3D",
  365. ],
  366. lengedName: "", // 图例名称
  367. imageNum: 1, //设备数量
  368. fillColor: "", //修改填充色 (主要针对防火风区以及石材铺装)
  369. SubType: "", //空间类型,区分石材铺装
  370. itemExplain:'', //图例说明 只针对石材铺装
  371. attrCards:[],
  372. spinning:false,
  373. getmajorId:''
  374. };
  375. },
  376. methods: {
  377. onChange(e) {
  378. this.precision = e.target.checked === true ? false : true;
  379. },
  380. changeBorder(value) {
  381. bus.$emit("changeBorder", value);
  382. },
  383. changeNumber() {
  384. bus.$emit("changeFont", this.fontSize);
  385. },
  386. // 改变字体大小
  387. changeFont() {
  388. bus.$emit("changeFont", this.fontSize);
  389. },
  390. // 改变线宽
  391. changeLineWidth() {
  392. bus.$emit("changeLineWidth", this.lineWidth);
  393. },
  394. // 改变文案
  395. changeTextArea() {
  396. bus.$emit("changeText", this.textMsg);
  397. },
  398. // 改变线的颜色
  399. changeBorderColor() {
  400. if (this.borderColor) {
  401. bus.$emit("changeBorderColor", this.borderColor);
  402. }
  403. },
  404. // 改变字体颜色
  405. changeFontColor(color) {
  406. if (color) {
  407. bus.$emit("changeFontColor", color);
  408. }
  409. },
  410. changebackColor(color) {
  411. if (color) {
  412. bus.$emit("changebackColor", color);
  413. }
  414. },
  415. customRequest(info) {
  416. const formData = new FormData();
  417. formData.append("file", info.file);
  418. const postParams = formData;
  419. uploadImg({ postParams }).then(res => {
  420. if (res.Result == "success") {
  421. bus.$emit("upadataImageUrl", res.EntityList[0]);
  422. this.$message.success(
  423. `${info.file.name} file uploaded successfully.`
  424. );
  425. } else {
  426. this.$message.error(`${info.file.name} file upload failed.`);
  427. }
  428. });
  429. },
  430. //更改图例名称
  431. changeLengedName() {
  432. bus.$emit("changeLengedName", this.lengedName);
  433. },
  434. changeImage(info) {
  435. const status = info.file.status;
  436. console.log(status);
  437. if (status !== "uploading") {
  438. console.log(info.file, info.fileList);
  439. }
  440. if (status === "done") {
  441. this.$message.success(`${info.file.name} file uploaded successfully.`);
  442. } else if (status === "error") {
  443. this.$message.error(`${info.file.name} file upload failed.`);
  444. }
  445. },
  446. handleEdit() {
  447. this.$refs.dialog.showModal();
  448. },
  449. // 修改设备数量
  450. changeImageNum() {
  451. if (!this.imageNum) {
  452. this.imageNum = 1;
  453. }
  454. bus.$emit("changeImageNum", this.imageNum);
  455. },
  456. changefillColor() {
  457. if (this.fillColor) {
  458. bus.$emit("changefillColor", this.fillColor);
  459. }
  460. },
  461. //设置缩小item为编辑状态
  462. OpenEditStatus() {
  463. bus.$emit("OpenEditStatus");
  464. },
  465. // 编辑图例说明
  466. changeitemExplain(){
  467. bus.$emit("changeitemExplain",this.itemExplain);
  468. },
  469. // 更改工程信息化数据
  470. changeAttachObjectIds(arr){
  471. bus.$emit('changeAttachObjectIds',arr)
  472. }
  473. },
  474. watch: {
  475. focusItemList: function(newval) {
  476. console.log('xxxxxxxxxxxxxxx',newval)
  477. const Item = newval.itemList[0];
  478. this.getmajorId = Item.data.Properties.GraphCategoryId;
  479. if (Item.data && Item.data.SubType) {
  480. this.SubType = Item.data.SubType;
  481. }else{
  482. this.SubType = '';
  483. }
  484. if (newval.itemList.length == 1) {
  485. if (newval.itemType == "baseText") {
  486. this.textMsg = Item.text;
  487. this.fontSize = Item.font.size;
  488. this.fontColor = Item.color.value;
  489. this.backColor = Item.backgroundColor.value;
  490. } else if (newval.itemType == "baseLine") {
  491. this.lineWidth = Item.lineWidth;
  492. this.borderColor = Item.strokeColor.value;
  493. if (Item.lineStyle == SLineStyle.Soild) {
  494. this.borderStyle = "solid";
  495. } else if (Item.lineStyle == SLineStyle.Dashed) {
  496. this.borderStyle = "dashed";
  497. } else if (Item.lineStyle == SLineStyle.Dotted) {
  498. this.borderStyle = "dotted";
  499. }
  500. } else if (
  501. newval.itemType == "Zone" ||
  502. newval.itemType == "Line" ||
  503. newval.itemType == "Image"
  504. ) {
  505. this.lengedName = Item.data.Name;
  506. this.itemExplain = '';
  507. if(Item.data.Properties.ItemExplain){
  508. this.itemExplain = Item.data.Properties.ItemExplain ? Item.data.Properties.ItemExplain : '';
  509. }
  510. if (newval.itemType == "Image") {
  511. this.imageNum = Item.num;
  512. this.color = Item.color.value;
  513. this.fontSize = Item.font.size;
  514. } else if (newval.itemType == "Line") {
  515. this.color = Item.color.value;
  516. this.fillColor = Item.fillColor.value;
  517. this.borderColor = Item.strokeColor.value;
  518. this.lineWidth = Item.lineWidth;
  519. }
  520. }
  521. }
  522. const location =[];
  523. let params ={};
  524. Item.data.AttachObjectIds.map(item=>{
  525. location.push(item.id)
  526. })
  527. if(newval.itemType == 'Zone'){
  528. this.spinning = true;
  529. if(location.length){
  530. params = {locationList:location}
  531. }else{
  532. params = {locationList:['']};
  533. }
  534. queryGlsmsLocation({plazaId: getUrlMsg().projectId},params).then(res=>{
  535. this.spinning = false;
  536. if(res.data.result =='success'){
  537. this.attrCards = res.data.data||[];
  538. }else{
  539. this.$message.error('工程信息化中的位置信息获取失败')
  540. }
  541. })
  542. }else if(newval.itemType == 'Image'){
  543. this.spinning = true;
  544. if(location.length){
  545. params = {assetnumList:location}
  546. }else{
  547. params = {assetnumList:['']};
  548. }
  549. queryGlsmsAsset({plazaId: getUrlMsg().projectId},params).then(res=>{
  550. this.spinning = false;
  551. if(res.data.result =='success'){
  552. this.attrCards = res.data.data||[];
  553. }else{
  554. this.$message.error('工程信息化中的设备信息获取失败')
  555. }
  556. })
  557. }
  558. }
  559. }
  560. };
  561. </script>
  562. <style scoped lang="less">
  563. /deep/ .ant-spin-nested-loading{
  564. height: 100% !important;
  565. .ant-spin-container{
  566. height: 100% !important;
  567. }
  568. }
  569. .attr-select {
  570. padding: 12px 16px;
  571. box-sizing: border-box;
  572. .grid-title {
  573. font-size: 12px;
  574. color: #8d9399;
  575. }
  576. .row {
  577. width: 100%;
  578. display: flex;
  579. justify-content: space-between;
  580. align-items: center;
  581. margin-top: 12px;
  582. .color-choice {
  583. & /deep/ .vue-swatches__trigger {
  584. width: 26px !important;
  585. height: 26px !important;
  586. border-radius: 0px !important;
  587. }
  588. }
  589. .row-tit {
  590. color: #1f2429;
  591. font-size: 14px;
  592. }
  593. }
  594. .grid {
  595. margin: 10px 15px;
  596. .grid-title {
  597. font-size: 12px;
  598. color: #8d9399;
  599. }
  600. }
  601. .grid-content {
  602. // margin-top: 10px;
  603. position: relative;
  604. }
  605. .icon-image {
  606. font-size: 25px;
  607. }
  608. .edit-option-btn {
  609. float: right;
  610. margin-top: -5px;
  611. }
  612. .attr-card {
  613. width: 250px;
  614. margin-bottom: 10px;
  615. white-space: normal;
  616. box-shadow: 0px 2px 6px 0px rgba(31, 36, 41, 0.05);
  617. border-radius: 4px;
  618. }
  619. .ant-upload.ant-upload-drag p.ant-upload-text {
  620. font-size: 14px;
  621. color: #c3c7cb;
  622. }
  623. .ant-upload.ant-upload-drag p.ant-upload-hint {
  624. color: #0091ff;
  625. }
  626. }
  627. .key-boards {
  628. .key-board {
  629. width: 52px;
  630. height: 24px;
  631. border-radius: 3px;
  632. border: 1px solid rgba(195, 199, 203, 1);
  633. font-size: 14px;
  634. color: #646a73;
  635. text-align: center;
  636. }
  637. /deep/ .ant-collapse-content {
  638. border-top: 1px solid #eff0f1;
  639. }
  640. }
  641. #attr-select {
  642. width: 100%;
  643. height: 100%;
  644. .attr-select-bottom {
  645. height: 100%;
  646. width: 100%;
  647. position: absolute;
  648. overflow-y: auto;
  649. padding-bottom: 400px;
  650. }
  651. }
  652. </style>