ConfigEidt.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <div style="position: relative">
  3. <div class="top-content">
  4. <div style="display: flex; position: relative">
  5. <img src="~@/assets/icons/back.png" alt="" @click="backPage" class="back-btn" />
  6. <el-select
  7. v-model="companySelet"
  8. class="m-2"
  9. placeholder="请选择相关公司"
  10. style="width: 216px"
  11. @change="changeCom"
  12. >
  13. <el-option
  14. v-for="item in companyList"
  15. :key="item.id"
  16. :label="item.value"
  17. :value="item.value"
  18. />
  19. </el-select>
  20. <div v-if="companySelet" style="display: flex; margin-top: 8px">
  21. <div class="label-workshop">选择标签:</div>
  22. <div>
  23. <el-radio-group v-model="label" size="10px" :border="true" style="display: flex">
  24. <el-radio-button
  25. v-for="item in labelList"
  26. :key="item.id"
  27. :label="item.id!"
  28. class="label-select"
  29. >{{ item.value }}</el-radio-button
  30. >
  31. </el-radio-group></div
  32. >
  33. </div>
  34. <el-upload
  35. ref="upload"
  36. class="upload-demo"
  37. :limit="1"
  38. :show-file-list="false"
  39. :on-exceed="handleExceed"
  40. :on-change="onSelectfile"
  41. :auto-upload="false"
  42. :before-upload="beforeAvatarUpload"
  43. >
  44. <template #trigger>
  45. <el-button :icon="Refresh" plain class="btn-top-refresh">替换照片</el-button>
  46. </template>
  47. </el-upload>
  48. <el-button v-if="saveSwitch" type="info" plain class="btn-top-save" @click="saveConfigPage"
  49. >保存为主页</el-button
  50. >
  51. <el-button v-else type="info" plain class="btn-top-save" @click="saveConfigMap"
  52. >保存为地图</el-button
  53. >
  54. <!-- <div>按钮</div> -->
  55. </div>
  56. </div>
  57. <div style="display: flex">
  58. <div class="workshop-content">
  59. <div class="workshop-title">车间列表</div>
  60. <el-input
  61. v-model="searchWorkshop"
  62. class="w-50 m-2"
  63. placeholder="请输入搜索内容"
  64. :suffix-icon="Search"
  65. style="width: 255px; margin-top: 11px"
  66. />
  67. <ul v-if="workshopList"
  68. ><li
  69. v-for="item in workshopList"
  70. :key="item.id"
  71. class="workshop-list"
  72. :class="{ 'active-workshop': activeId === item.id }"
  73. @click="configWorkshop(item)"
  74. ><el-icon><House /></el-icon
  75. ><div style="margin-left: 5px; margin-top: -4px">{{ item.value }}</div></li
  76. ></ul
  77. >
  78. <div v-else class="workshop-tip">提示:请先选择相应公司和照片</div>
  79. </div>
  80. <div>
  81. <div class="upload" :class="{ 'avatar-show': imageUrl }">
  82. <el-upload
  83. class="avatar-uploader"
  84. :auto-upload="false"
  85. :on-change="onSelectfile"
  86. :before-upload="beforeAvatarUpload"
  87. >
  88. <template #trigger>
  89. <img src="~@/assets/icons/upload.png" alt="" class="upload-pic" />
  90. </template>
  91. </el-upload>
  92. <!-- <div class="upload-tip">只支持.jpg格式</div> -->
  93. </div>
  94. <img v-if="imageUrl" :src="imageUrl" class="preview-image" />
  95. <!-- <div>222</div> -->
  96. </div></div
  97. >
  98. <el-tooltip
  99. class="box-item position-tooltip"
  100. effect="dark"
  101. content="显示侧边栏"
  102. offset="12"
  103. placement="left"
  104. @click="showEditConfig"
  105. >
  106. <div
  107. v-if="leftShow"
  108. class="circle-rectangle"
  109. :class="{ 'shape-shadow': shadow }"
  110. @mouseover="shadowAdd"
  111. @mouseout="shadowRemove"
  112. @click="dialogReopen"
  113. >
  114. <el-icon class="left-icon" size="16px"><ArrowLeftBold /></el-icon>
  115. <el-icon style="margin-top: 7px" size="16px"><ArrowLeftBold /></el-icon>
  116. <!-- <el-icon class="left-icon"><DArrowLeft /></el-icon> -->
  117. </div>
  118. <!-- <img src="~@/assets/icons/slide.png" alt="" class="dialog-btn" /> -->
  119. </el-tooltip>
  120. <ConfigDialog
  121. ref="configDrawer"
  122. :title="configTitle"
  123. @on-close="onClose"
  124. @save-config="saveConfig"
  125. class="drawer-position"
  126. />
  127. <ConfigFinish
  128. :visible="visibleResult"
  129. :status="configStatus"
  130. @on-close="closeResult"
  131. class="feedback-position"
  132. />
  133. </div>
  134. </template>
  135. <script lang="ts" setup>
  136. import { ref } from 'vue';
  137. import { Refresh, Search, ArrowLeftBold, House } from '@element-plus/icons-vue';
  138. import ConfigDialog from './component/ConfigDrawer.vue';
  139. import ConfigFinish from './component/ConfigFinish.vue';
  140. // import { picList } from '../constant';
  141. import { labelList, companyList, workshopList } from './constant';
  142. import { ElMessage, genFileId } from 'element-plus';
  143. import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus';
  144. // import upload, { UploadRawFile, genFileId } from 'element-plus/es/components/upload';
  145. import { useRouter } from 'vue-router';
  146. const router = useRouter();
  147. // const props = defineProps<{
  148. // pageShow: boolean;
  149. // // workshopTemplateList: WorkshopModuleType[];
  150. // }>();
  151. // const emit = defineEmits<{
  152. // // (e: 'update:modelValue'): unknown;
  153. // (e: 'onClose'): unknown;
  154. // }>();
  155. const label = ref('');
  156. const companySelet = ref('');
  157. const searchWorkshop = ref('');
  158. const saveSwitch = ref<boolean>(true);
  159. const changeCom = () => {
  160. saveSwitch.value = true;
  161. };
  162. const configStatus = ref(true);
  163. // const replacePic = () => {};
  164. const saveConfigPage = () => {
  165. saveSwitch.value = false;
  166. // router.push('/page-config/config');
  167. };
  168. //总体的保存,将整个数据传过去
  169. const visibleResult = ref(false);
  170. const saveConfigMap = () => {
  171. //这里需要控制成功或者失败的弹出框
  172. visibleResult.value = true;
  173. //configStatus修改状态,决定成功还是失败
  174. // saveSwitch.value = true;
  175. // router.push('/page-config/config');
  176. };
  177. const imageUrl = ref('');
  178. const configDrawer = ref();
  179. const backPage = () => {
  180. router.push('/page-config/layout');
  181. };
  182. const beforeAvatarUpload = (rawFile) => {
  183. if (rawFile.type !== 'image/jpeg') {
  184. ElMessage.error('Avatar picture must be JPG format!');
  185. return false;
  186. }
  187. // else if (rawFile.size / 1024 / 1024 > 2) {
  188. // ElMessage.error('Avatar picture size can not exceed 2MB!');
  189. // return false;
  190. // }
  191. return true;
  192. };
  193. const onSelectfile = (uploadFile) => {
  194. imageUrl.value = URL.createObjectURL(uploadFile.raw!);
  195. };
  196. const upload = ref<UploadInstance>();
  197. const handleExceed: UploadProps['onExceed'] = (files) => {
  198. upload.value!.clearFiles();
  199. const file = files[0] as UploadRawFile;
  200. file.uid = genFileId();
  201. upload.value!.handleStart(file);
  202. };
  203. const activeId = ref();
  204. const configTitle = ref();
  205. const visibleDrawer = ref();
  206. //编辑车间
  207. const configWorkshop = (item) => {
  208. configDrawer.value.openDialog();
  209. visibleDrawer.value = true;
  210. configTitle.value = item.value;
  211. activeId.value = item.id;
  212. };
  213. const showEditConfig = () => {};
  214. // const label = ref('');
  215. const shadow = ref(false);
  216. const shadowAdd = () => {
  217. shadow.value = true;
  218. };
  219. const shadowRemove = () => {
  220. shadow.value = false;
  221. };
  222. const dialogReopen = () => {
  223. configDrawer.value.openDialog();
  224. };
  225. //左边的浮动按钮
  226. const leftShow = ref(false);
  227. const onClose = (val) => {
  228. leftShow.value = val;
  229. };
  230. //需要从子组件中获得当前保存的车间数据
  231. const saveConfig = (val) => {
  232. console.log(val);
  233. };
  234. const closeResult = () => {
  235. visibleResult.value = false;
  236. };
  237. </script>
  238. <style lang="scss" scoped>
  239. // .proCard {
  240. // padding: 0px;
  241. // }
  242. .top-content {
  243. padding: 0px;
  244. background-color: white;
  245. position: relative;
  246. }
  247. .back-btn {
  248. width: 32px;
  249. height: 32px;
  250. margin-top: 7px;
  251. margin-right: 20px;
  252. }
  253. .btn-top-refresh {
  254. position: absolute;
  255. margin-top: 14px;
  256. right: 137px;
  257. // left: 1437px;
  258. }
  259. .btn-top-save {
  260. position: absolute;
  261. // margin-top: 8px;
  262. margin-top: 6px;
  263. right: 15px;
  264. }
  265. .label-workshop {
  266. font-size: 14px;
  267. font-weight: 400;
  268. margin-left: 36px;
  269. margin-top: 6px;
  270. margin-right: 16px;
  271. }
  272. .workshop-content {
  273. margin-top: 10px;
  274. background-color: white;
  275. // padding-left: 15px;
  276. // margin-left: 10px;
  277. margin-right: 10px;
  278. width: 271px;
  279. height: 800px;
  280. border: 1px solid #b3b3b3;
  281. }
  282. .workshop-title {
  283. font-size: 14px;
  284. margin-top: 25px;
  285. margin-left: 15px;
  286. font-weight: 500;
  287. color: rgba(0, 0, 0, 0.85);
  288. }
  289. // .label-select {
  290. // }
  291. // .el-radio-button__inner
  292. ::v-deep.el-radio-button {
  293. margin-right: 8px;
  294. box-shadow: none;
  295. border-radius: 4px !important;
  296. border: 1px solid #d9d9d9 !important;
  297. }
  298. .workshop-list {
  299. font-size: 14px;
  300. width: 211px;
  301. margin-top: 10px;
  302. margin-left: 15px;
  303. font-weight: 400;
  304. color: rgba(0, 0, 0, 0.85);
  305. cursor: pointer;
  306. display: flex;
  307. }
  308. .workshop-tip {
  309. margin-left: 15px;
  310. margin-top: 12px;
  311. font-size: 14px;
  312. font-weight: 400;
  313. color: rgba(0, 0, 0, 0.65);
  314. }
  315. .upload-pic {
  316. z-index: 99;
  317. width: 593px;
  318. height: 435px;
  319. // margin-left: ;
  320. }
  321. .active-workshop {
  322. background: rgba(24, 144, 255, 0.502);
  323. }
  324. .avatar-uploader .el-upload {
  325. border: 1px dashed var(--el-border-color);
  326. border-radius: 6px;
  327. width: 593px;
  328. height: 435px;
  329. cursor: pointer;
  330. position: relative;
  331. overflow: hidden;
  332. color: #8c939d;
  333. transition: var(--el-transition-duration-fast);
  334. }
  335. .avatar-uploader .el-upload:hover {
  336. border-color: var(--el-color-primary);
  337. }
  338. // .el-icon.avatar-uploader-icon {
  339. // font-size: 28px;
  340. // color: #8c939d;
  341. // width: 178px;
  342. // height: 178px;
  343. // text-align: center;
  344. // margin-top: -60px;
  345. // }
  346. .upload {
  347. position: absolute;
  348. left: 428px;
  349. top: 174px;
  350. }
  351. // .upload-tip {
  352. // margin-top: 5px;
  353. // font-size: 22px;
  354. // font-weight: 350;
  355. // color: #3d3d3d;
  356. // opacity: 0.4;
  357. // text-align: center;
  358. // }
  359. .uploader-text {
  360. margin-top: -60px;
  361. margin-left: 50px;
  362. font-size: 22px;
  363. font-weight: 350;
  364. color: #3d3d3d;
  365. opacity: 0.4;
  366. }
  367. // .preview-container {
  368. // width: 178px;
  369. // height: 178px;
  370. // position: relative;
  371. // }
  372. .preview-image {
  373. min-width: 100%;
  374. min-height: 100%;
  375. object-fit: contain;
  376. }
  377. .avatar-show {
  378. display: none;
  379. }
  380. .drawer-position {
  381. position: absolute;
  382. right: 0px;
  383. // left: 1150px;
  384. top: 74px;
  385. z-index: 99;
  386. opacity: 1;
  387. background: #ffffff;
  388. }
  389. .dialog-btn {
  390. position: absolute;
  391. right: 0px;
  392. top: 66px;
  393. }
  394. .position-tooltip {
  395. margin-right: -10px;
  396. }
  397. .circle-rectangle {
  398. width: 40px;
  399. height: 30px;
  400. border-radius: 50% 0% 0% 50%;
  401. position: absolute;
  402. right: 0px;
  403. top: 66px;
  404. background-color: white;
  405. display: flex;
  406. }
  407. .shape-shadow {
  408. filter: drop-shadow(5px 5px 10px rgb(102, 100, 100));
  409. }
  410. .left-icon {
  411. margin-top: 7px;
  412. margin-left: 8px;
  413. margin-right: -7px;
  414. }
  415. .feedback-position {
  416. position: absolute;
  417. left: 460px;
  418. top: 150px;
  419. z-index: 9999;
  420. }
  421. </style>