dialogEditProperty.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="jt-wall-dialog">
  3. <el-dialog
  4. draggable
  5. :modal="false"
  6. :destroy-on-close="false"
  7. v-model="dialogVisible"
  8. :title="title"
  9. :style="{ left: '120px', background: 'rgb(0 44 126 / 68%)', height: '400px', width: '180px', top: '100px' }"
  10. @close="closeDialog"
  11. @open="openDialog"
  12. >
  13. <template #header>
  14. <div slot="title" class="header-title">
  15. <span style="line-height:24px;font-size:18px;color:#fff;font-family: 'Alimama_ShuHeiTi_Bold'">{{ title }}</span>
  16. </div>
  17. </template>
  18. <template #default>
  19. <div class="odin-dialog__content">
  20. <div class="jt-wall-row" v-show="isShowHeight">
  21. <div class="col-left">高度</div>
  22. <div class="col-main"><el-input v-model="wallHeight" placeholder="输入高度值" clearable /></div>
  23. </div>
  24. <div class="jt-wall-row" v-show="isShowLineWidth">
  25. <div class="col-left">线宽</div>
  26. <div class="col-main"><el-input v-model="lineWidth" placeholder="输入宽度值" clearable /></div>
  27. </div>
  28. <div class="jt-wall-row" v-show="isShowGlowpower">
  29. <div class="col-left">发光强度</div>
  30. <div class="col-main"><el-input v-model="glowPower" placeholder="输入发光强度0~1" clearable /></div>
  31. </div>
  32. <div class="jt-wall-row" v-show="isShowColor">
  33. <div class="col-left">颜色</div>
  34. <div class="col-main">
  35. <el-config-provider :locale="locale"><el-color-picker v-model="color" show-alpha :predefine="predefineColors" label="12" /></el-config-provider>
  36. </div>
  37. </div>
  38. <div class="jt-wall-row" v-show="isShowDirection">
  39. <div class="col-left">流动方向</div>
  40. <div class="col-main">
  41. <el-radio-group v-model="radioDirection">
  42. <el-radio-button v-for="(item, index) in directions" :label="item.key" v-model="item.value" @change="directionChange" />
  43. </el-radio-group>
  44. </div>
  45. </div>
  46. <div class="jt-wall-row" v-show="isShowOrder">
  47. <div class="col-left">流动顺序</div>
  48. <div class="col-main">
  49. <el-radio-group v-model="radioOrder"><el-radio-button v-for="(item, index) in orders" :label="item.key" v-model="item.value" /></el-radio-group>
  50. </div>
  51. </div>
  52. <div class="jt-wall-row" v-show="isShowCount">
  53. <div class="col-left">重复数量</div>
  54. <div class="col-main"><el-input v-model="yCount" placeholder="输入1~100" clearable /></div>
  55. </div>
  56. <div class="jt-wall-row" v-show="isShowText" style="height: 60px;">
  57. <div class="col-left">文字内容</div>
  58. <div class="col-main"><el-input v-model="txtContent" placeholder="输入显示的文字内容" clearable type="textarea" :rows="2" /></div>
  59. </div>
  60. <div class="jt-wall-row" v-show="isShowOutlineWidth">
  61. <div class="col-left">描边宽度</div>
  62. <div class="col-main"><el-input v-model="outlineWidth" placeholder="输入宽度值" clearable /></div>
  63. </div>
  64. <div class="jt-wall-row" v-show="isShowOutlineColor">
  65. <div class="col-left">描边颜色</div>
  66. <div class="col-main">
  67. <el-config-provider :locale="locale"><el-color-picker v-model="outlineColor" show-alpha :predefine="predefineColors" label="12" /></el-config-provider>
  68. </div>
  69. </div>
  70. <div class="el-body-foot">
  71. <el-button-group class="ml-4">
  72. <el-button type="primary" :icon="Edit" @click="submit()">修改</el-button>
  73. <el-button type="danger" :icon="Delete">删除</el-button>
  74. </el-button-group>
  75. </div>
  76. </div>
  77. </template>
  78. </el-dialog>
  79. </div>
  80. </template>
  81. <script setup>
  82. /* 引入ref和reactive 其中ref用于简单类型 reactive用于复杂类型 */
  83. import { computed, ref, reactive, toRefs, watch } from 'vue';
  84. import { ElDialog } from 'element-plus';
  85. import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
  86. import en from 'element-plus/dist/locale/en.mjs';
  87. import { ArrowLeft, ArrowRight, Delete, Edit, Share } from '@element-plus/icons-vue';
  88. import { param, type } from 'jquery';
  89. import { DrawTools } from '../CrMap/DrawTools.js';
  90. const language = ref('zh-cn');
  91. const locale = computed(() => (language.value === 'zh-cn' ? zhCn : en));
  92. const props = defineProps({
  93. params: {
  94. id: {
  95. type: String,
  96. default: () => undefined
  97. },
  98. height: {
  99. type: Number,
  100. default: () => 13
  101. },
  102. color: {
  103. type: String,
  104. default: () => '255,255,0,0.9'
  105. },
  106. direction: {
  107. type: String,
  108. default: () => 'horizontal'
  109. },
  110. order: {
  111. type: String,
  112. default: () => '+'
  113. },
  114. count: {
  115. type: Number,
  116. default: () => 2
  117. },
  118. text: {
  119. type: String,
  120. default: () => ''
  121. },
  122. lineWidth: {
  123. type: Number,
  124. default: () => 2
  125. },
  126. glowPower: {
  127. type: Number,
  128. default: () => 0.25
  129. },
  130. outlineWidth: {
  131. type: Number,
  132. default: () => 0
  133. },
  134. outlineColor: {
  135. type: String,
  136. default: () => '255,255,0,0.9'
  137. }
  138. },
  139. showDialog: {
  140. type: Boolean,
  141. default: () => false
  142. }
  143. });
  144. const emit = defineEmits(['submit', 'update:showDialog', 'update:params']);
  145. /* 默认颜色 */
  146. const predefineColors = ref([
  147. '#ff4500',
  148. '#ff8c00',
  149. '#ffd700',
  150. '#90ee90',
  151. '#00ced1',
  152. '#1e90ff',
  153. '#c71585',
  154. 'rgba(255, 69, 0, 0.68)',
  155. 'rgb(255, 120, 0)',
  156. 'hsv(51, 100, 98)',
  157. 'hsva(120, 40, 94, 0.5)',
  158. 'hsl(181, 100%, 37%)',
  159. 'hsla(209, 100%, 56%, 0.73)',
  160. '#c7158577'
  161. ]);
  162. /* 初始赋值 */
  163. const isShowColor = ref(false);
  164. const isShowText = ref(false);
  165. const isShowHeight = ref(false);
  166. const isShowDirection = ref(false);
  167. const isShowOrder = ref(false);
  168. const isShowCount = ref(false);
  169. const isLineWidth = ref(false);
  170. const isShowLineWidth = ref(false);
  171. const isShowGlowpower = ref(false);
  172. const isShowOutlineWidth = ref(false);
  173. const isShowOutlineColor = ref(false);
  174. const color = ref(props.params.color);
  175. const title = ref('属性编辑');
  176. const dialogVisible = ref(props.showDialog);
  177. const directions = reactive([{ key: '左右', value: 'horizontal' }, { key: '上下', value: 'vertical' }]);
  178. const orders = reactive([]);
  179. const radioDirection = ref('');
  180. const radioOrder = ref('');
  181. const wallHeight = ref(0);
  182. const yCount = ref(0);
  183. const txtContent = ref('');
  184. const lineWidth = ref(0);
  185. const glowPower = ref(0.25);
  186. const outlineWidth = ref(0);
  187. const outlineColor = ref(props.params.outlineColor);
  188. /* 根据传递的属性更新 */
  189. updateParams(props.params);
  190. /* 监听参数的变化 */
  191. watch(
  192. () => props.showDialog,
  193. (newVal, oldVal) => {
  194. dialogVisible.value = newVal;
  195. }
  196. );
  197. watch(props.params, (newVal, oldVal) => {
  198. updateParams(newVal);
  199. });
  200. /**
  201. * 根据参数更新内容
  202. * @param {JSON} params 参数
  203. */
  204. function updateParams(params) {
  205. _setShowControls(false);
  206. /* 根据参数的显示不同的内容 */
  207. if (params.id === DrawTools.DrawType.TextWall) {
  208. title.value = '广告牌编辑';
  209. isShowColor.value = true;
  210. isShowText.value = true;
  211. isShowHeight.value = true;
  212. } else if (params.id === DrawTools.DrawType.DynamicWall) {
  213. title.value = '动态围栏编辑';
  214. isShowColor.value = true;
  215. isShowDirection.value = true;
  216. isShowOrder.value = true;
  217. isShowCount.value = true;
  218. isShowHeight.value = true;
  219. } else if (params.id === DrawTools.DrawType.NormalWall) {
  220. title.value = '普通围栏编辑';
  221. isShowColor.value = true;
  222. isShowHeight.value = true;
  223. } else if (params.id === DrawTools.DrawType.Circle) {
  224. title.value = '贴地圆编辑';
  225. isShowColor.value = true;
  226. isShowOutlineColor.value = true;
  227. isShowOutlineWidth.value = true;
  228. } else if (params.id === DrawTools.DrawType.DynamicCircle) {
  229. title.value = '扩散圆编辑';
  230. isShowColor.value = true;
  231. isShowCount.value = true;
  232. } else if (params.id === DrawTools.DrawType.House) {
  233. title.value = '房屋编辑';
  234. isShowColor.value = true;
  235. isShowHeight.value = true;
  236. } else if (params.id === DrawTools.DrawType.VideoWall) {
  237. title.value = '视频墙编辑';
  238. } else if (params.id === DrawTools.DrawType.Polyline) {
  239. title.value = '贴地线编辑';
  240. isShowColor.value = true;
  241. isShowLineWidth.value = true;
  242. } else if (params.id === DrawTools.DrawType.ArrowPolyline) {
  243. title.value = '箭头线编辑';
  244. isShowColor.value = true;
  245. isShowLineWidth.value = true;
  246. } else if (params.id === DrawTools.DrawType.DynamicPolyline) {
  247. title.value = '动态线编辑';
  248. isShowColor.value = true;
  249. isShowOrder.value = true;
  250. isShowCount.value = true;
  251. isShowLineWidth.value = true;
  252. } else if (params.id === DrawTools.DrawType.GrowPolyline) {
  253. title.value = '发光线编辑';
  254. isShowColor.value = true;
  255. isShowLineWidth.value = true;
  256. isShowGlowpower.value = true;
  257. } else if (params.id === DrawTools.DrawType.OultliePolyline) {
  258. title.value = '描边线编辑';
  259. isShowColor.value = true;
  260. isShowLineWidth.value = true;
  261. isShowOutlineColor.value = true;
  262. isShowOutlineWidth.value = true;
  263. } else if (params.id === DrawTools.DrawType.Polygon) {
  264. title.value = '贴地面编辑';
  265. isShowColor.value = true;
  266. isShowOutlineColor.value = true;
  267. isShowOutlineWidth.value = true;
  268. } else if (params.id === DrawTools.DrawType.Polygon) {
  269. title.value = '贴地面编辑';
  270. isShowColor.value = true;
  271. isShowOutlineColor.value = true;
  272. isShowOutlineWidth.value = true;
  273. } else if (params.id === DrawTools.DrawType.SpatialLine) {
  274. title.value = '空间线编辑';
  275. isShowColor.value = true;
  276. isShowLineWidth.value = true;
  277. } else {
  278. _setShowControls(true);
  279. }
  280. color.value = params.color;
  281. /* 判断方向及顺序 */
  282. if (params.direction === 'horizontal') {
  283. radioDirection.value = directions[0].key;
  284. Object.assign(orders, [{ key: '自左至右', value: '-' }, { key: '自右至左', value: '+' }]);
  285. if (params.order === '-') {
  286. radioOrder.value = orders[0].key;
  287. } else {
  288. radioOrder.value = orders[1].key;
  289. }
  290. } else {
  291. radioDirection.value = directions[1].key;
  292. Object.assign(orders, [{ key: '自上至下', value: '+' }, { key: '自下至上', value: '-' }]);
  293. if (params.order === '+') {
  294. radioOrder.value = orders[0].key;
  295. } else {
  296. radioOrder.value = orders[1].key;
  297. }
  298. }
  299. wallHeight.value = params.height;
  300. yCount.value = params.count;
  301. txtContent.value = params.text;
  302. lineWidth.value = params.lineWidth;
  303. glowPower.value = params.power;
  304. outlineColor.value = params.outlineColor;
  305. outlineWidth.value = params.outlineWidth;
  306. console.log('===设置参数显示>>>', params.lineWidth);
  307. }
  308. /**
  309. * 显示控件设置
  310. * @param {Boolean} isShow 是否显示
  311. */
  312. function _setShowControls(isShow) {
  313. isShowColor.value = isShow;
  314. isShowText.value = isShow;
  315. isShowDirection.value = isShow;
  316. isShowOrder.value = isShow;
  317. isShowCount.value = isShow;
  318. isShowHeight.value = isShow;
  319. isShowLineWidth.value = isShow;
  320. isShowGlowpower.value = isShow;
  321. isShowOutlineColor.value = isShow;
  322. isShowOutlineWidth.value = isShow;
  323. }
  324. /**
  325. * 对外部公开的函数
  326. */
  327. defineExpose({
  328. updateParams
  329. });
  330. /**
  331. * 提交更改
  332. */
  333. function submit() {
  334. emit('submit', {
  335. id: props.params.id,
  336. height: wallHeight.value,
  337. color: color.value,
  338. direction: directions.filter(item => {
  339. return item.key === radioDirection.value;
  340. })[0].value,
  341. order: orders.filter(item => {
  342. return item.key === radioOrder.value;
  343. })[0].value,
  344. count: yCount.value,
  345. text: txtContent.value,
  346. lineWidth: lineWidth.value,
  347. power: glowPower.value,
  348. outlineColor: outlineColor.value,
  349. outlineWidth: outlineWidth.value
  350. });
  351. dialogVisible.value = false;
  352. }
  353. /**
  354. * 材质方向选择事件
  355. * @param {Object} e
  356. */
  357. function directionChange(e) {
  358. if (e.target.value === directions[0].key) {
  359. Object.assign(orders, [{ key: '自左至右', value: '-' }, { key: '自右至左', value: '+' }]);
  360. radioOrder.value = orders[0].key;
  361. } else if (e.target.value === directions[1].key) {
  362. Object.assign(orders, [{ key: '自上至下', value: '-' }, { key: '自下至上', value: '+' }]);
  363. radioOrder.value = orders[0].key;
  364. }
  365. }
  366. /**
  367. * 窗口关闭,修改双向绑定值
  368. */
  369. function closeDialog() {
  370. emit('update:showDialog', false);
  371. }
  372. /**
  373. * 窗口打开
  374. */
  375. function openDialog() {
  376. updateParams(props.params);
  377. }
  378. </script>
  379. <style lang="scss">
  380. /* 墙对话框内容行样式 */
  381. .jt-wall-row {
  382. display: flex;
  383. flex-direction: row;
  384. height: 40px;
  385. align-items: center;
  386. /* 行左侧标题样式 */
  387. .col-left {
  388. display: flex;
  389. align-items: center;
  390. justify-content: right;
  391. width: 60px;
  392. font-family: 'Alimama_ShuHeiTi_Bold';
  393. font-weight: bold;
  394. margin-right: 8px;
  395. }
  396. /* 主要内容样式 */
  397. .col-main {
  398. flex: 1;
  399. display: flex;
  400. flex-direction: row;
  401. .el-input--suffix {
  402. background-color: rgba(255, 255, 255, 0);
  403. }
  404. .el-input--suffix * {
  405. background-color: rgba(255, 255, 255, 0);
  406. color: rgba(255, 255, 255, 1);
  407. }
  408. }
  409. }
  410. /* 墙对话框整体样式 */
  411. .jt-wall-dialog {
  412. pointer-events: none; // ***覆盖层元素增加可穿透点击事件***
  413. .el-dialog {
  414. pointer-events: auto; // ***弹窗层元素不可穿透点击事件(不影响弹窗层元素的点击事件)***
  415. position: absolute !important; //将通知框的position改成absolute,可以在某个div进行显示
  416. background: rgb(5 45 155 / 70%);
  417. min-width: 280px;
  418. overflow: hidden;
  419. /* 对话框标题头样式 */
  420. .el-dialog__header {
  421. background: url('../../assets/image/backheader.png') no-repeat;
  422. margin-right: 0px;
  423. padding: 6px;
  424. }
  425. /* 对话框关闭按钮的样式 */
  426. .el-dialog__headerbtn {
  427. height: 34px;
  428. }
  429. /* 对话框主体的样式 */
  430. .el-dialog__body {
  431. padding: 10px;
  432. color: #fff;
  433. }
  434. /* 颜色选择器的宽度 */
  435. .el-color-picker__trigger {
  436. width: 120px;
  437. }
  438. .el-body-foot {
  439. position: absolute;
  440. bottom: 8px;
  441. right: 8px;
  442. }
  443. }
  444. }
  445. </style>