attr_select.vue 18 KB

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