UploadInfor.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <div class="upload_infor">
  3. <form>
  4. <div class="dataName">
  5. <span>资料名称</span><input type="text" class="inputStyle focusStyle" v-model="inforName" @focus="hideTip" @blur="checkName()">
  6. <p v-show="tipFlag">资料名称不能重复,请重新输入</p>
  7. </div>
  8. <div class="inforDes">
  9. <span>资料描述</span><textarea name="inforDes" cols="40" rows="4" class="focusStyle" v-model="inforDes"></textarea>
  10. </div>
  11. <div class="selectType">
  12. <p>选择类型</p>
  13. <div>
  14. <span>素材时间</span>
  15. <select name="materialTime" class="selectStyle" v-model="materialTime" autocomplete="off" @change="materialTimeChange">
  16. <option value="" selected>请选择</option>
  17. <option v-for="(time, index) in materialTimeList" :key="index" :value="time">{{time}}</option>
  18. </select>
  19. <span>经销商范围</span>
  20. <select class="selectStyle" v-model="scope" autocomplete="off" @change="scopeChange">
  21. <option value="" selected>共通</option>
  22. <option value="part">部分</option>
  23. </select>
  24. </div>
  25. </div>
  26. <div v-show="isShow">
  27. <p>权限设置</p>
  28. <div class="addByArea">
  29. <span>按区域添加</span>
  30. <div v-for="(item, index) in areaList" :key="index">
  31. <input type="checkbox" :value="item.sign" v-model="checkedBoxList"><span>{{item.area}}</span>
  32. </div>
  33. <button @click.prevent="addByArea">添加</button>
  34. </div>
  35. <div class="addByCustomize">
  36. <span>自定义添加</span>
  37. <input id="drl" list="drls" class="inputStyle focusStyle" v-model="addByCustomize"/>
  38. <datalist id="drls" value='12'>
  39. <option value="BMW"/>
  40. <option value="Ford"/>
  41. <option value="Volvo"/>
  42. </datalist>
  43. <button @click.prevent="addBySelf">添加</button>
  44. </div>
  45. <div class="addByGroup">
  46. <span>按小组添加</span>
  47. <div class="selectBox">
  48. <img src="../../img/select.png" @click="showOption">
  49. <div class="optionBox" v-if="optionFlag">
  50. <ul>
  51. <li v-for="(item, index) in groupList" :key="index">
  52. <p>{{item}}</p>
  53. <img src="../../img/add.png" v-if="addFlag[index]" @click="addGroup(index)">
  54. <img src="../../img/delete.png" v-else @click="deleteGroup(index)">
  55. </li>
  56. </ul>
  57. </div>
  58. </div>
  59. <button @click.prevent="addByGroup">添加</button>
  60. </div>
  61. </div>
  62. </form>
  63. <div class="count">
  64. <Count :sum='sum'/>
  65. </div>
  66. <div class="table">
  67. <UpLoadTable
  68. :trStyle='trStyle'
  69. :tableHeader='tableHeader'
  70. :tableData='tableData'
  71. :tableHeadStyle='tableHeadStyle'
  72. :discolor='discolor'
  73. @change_icon='changeIcon'
  74. :operationStyle='operationStyle'
  75. :imgFlag='imgFlag'
  76. />
  77. </div>
  78. <div class="page">
  79. <Tablepage
  80. :totalPage='totalPage'
  81. :currentPage='currentPage'
  82. @change_page='changePage'
  83. @jump_page='jumpPage'
  84. />
  85. </div>
  86. <div class="uploadFile">
  87. <p>附件</p>
  88. <p class="fileDes">{{fileDes}}</p>
  89. <label for="fileInput" @change="getFileInfo">导入<input type="file" name="fileName" id="fileInput"></label>
  90. </div>
  91. <button @click="submit" class="submitBtn">提交</button>
  92. </div>
  93. </template>
  94. <script>
  95. import UpLoadTable from '../../components/UploadInforTable';
  96. import Count from '../../components/Count';
  97. import Tablepage from '../../components/TablePage';
  98. import { AREASLIST, MATERIALTIMESLIST, TABLEHEADS,TABLEHEADSTYLES, TRSSTYLE, GROUPLISTS, OPERATIONSTYLES } from '../../tableConfig/uploadinfo';
  99. export default {
  100. props:{
  101. isManufacturer: {
  102. type: String,
  103. default: 'distributor'
  104. },
  105. },
  106. components: {
  107. UpLoadTable,
  108. Count,
  109. Tablepage
  110. },
  111. watch: {
  112. scope(val) {
  113. if(val === 'part') {
  114. this.isShow = true;
  115. } else [
  116. this.isShow = false
  117. ]
  118. }
  119. },
  120. data() {
  121. return {
  122. tipFlag: false, // 是否展示提示
  123. isShow: false, // 共通时不展示权限设置
  124. inforName: '',
  125. inforDes: '',
  126. materialTime: '',
  127. scope: '',
  128. checkedBoxList: [], // 多选框选中的值
  129. addByCustomize: '',
  130. addGroupList: [], // 添加的小组
  131. addFlag: [true, true, true, true, true, true], // 长度等于groupList.length
  132. optionFlag: false, // 是否展示按小组添加的选择栏
  133. fileDes: '', // 上传的文件名
  134. // 表格配置
  135. sum: 240, // 一共有多少条数据
  136. pageSize: 20, // 每页展示的数据
  137. discolor: false, // 是否隔行变色
  138. currentPage: 1,
  139. areaList: AREASLIST, // 按区域添加
  140. groupList: GROUPLISTS, // 按小组添加
  141. materialTimeList: MATERIALTIMESLIST, // 素材时间
  142. tableHeader: TABLEHEADS, // 表头
  143. tableData: [{name: '北京博瑞',code: 'L020',area: '东区'},{name: 'a',code: 'a',area: 'N'},{name: 'a',code: 'a',area: 'N'}],
  144. tableHeadStyle: TABLEHEADSTYLES, // 表头样式
  145. operationStyle: OPERATIONSTYLES,// 筛选图片样式
  146. imgFlag: new Array(20).fill(true), // 筛选栏用添加图片还是删除图片
  147. trStyle: TRSSTYLE // 表格tr样式
  148. // 文件
  149. }
  150. },
  151. computed:{
  152. // 表格总页数
  153. totalPage() {
  154. return Math.ceil(this.sum/this.pageSize);
  155. }
  156. },
  157. methods: {
  158. // 检查名字是否重复 失去焦点判断
  159. checkName: function() {
  160. if(this.inforName==1) {
  161. this.tipFlag = true;
  162. }
  163. },
  164. // 名字不重复,隐藏提示
  165. hideTip: function() {
  166. this.tipFlag = false;
  167. },
  168. // 素材时间变化
  169. materialTimeChange: function() {
  170. console.log(this.materialTime);
  171. },
  172. // 进销商范围变化
  173. scopeChange: function() {
  174. console.log(this.scope)
  175. },
  176. // 显示隐藏按小组添加下拉框
  177. showOption() {
  178. this.optionFlag = !this.optionFlag;
  179. },
  180. // 点击按区域添加button
  181. addByArea: function() {
  182. console.log(this.checkedBoxList);
  183. },
  184. // 自定义添加
  185. addBySelf: function() {
  186. console.log(this.addByCustomize);
  187. },
  188. // 按小组添加,增加小组
  189. addGroup: function(index) {
  190. this.addFlag.splice(index, 1, false);
  191. console.log( this.addFlag);
  192. // 添加数据
  193. },
  194. // 按小组添加,删除小组
  195. deleteGroup: function(index) {
  196. this.addFlag.splice(index, 1, true);
  197. // 删除数据
  198. },
  199. // 点击按按小组添加按钮
  200. addByGroup: function() {
  201. this.addFlag.forEach((item, index) => {
  202. if(!item) {
  203. this.addGroupList.push(this.groupList[index]);
  204. }
  205. });
  206. console.log(JSON.parse(JSON.stringify(this.addGroupList)));
  207. this.optionFlag = false;
  208. },
  209. // 筛选
  210. changeIcon: function(i) {
  211. this.imgFlag.splice(i,1,!this.imgFlag[i]);
  212. console.log(i)
  213. },
  214. // 获取某一页面的数据,展示在表格
  215. changePage: function(page) {
  216. this.currentPage = page;
  217. console.log(page);
  218. },
  219. // 点击上一页,下一页,首页,尾页
  220. jumpPage: function(item) {
  221. switch(item) {
  222. case 1:
  223. this.currentPage = 1;
  224. break;
  225. case 2:
  226. this.currentPage = this.currentPage - 1;
  227. break;
  228. case 3:
  229. this.currentPage = this.currentPage + 1;
  230. break;
  231. case 4:
  232. this.currentPage = this.totalPage;
  233. break;
  234. }
  235. console.log(this.currentPage);
  236. },
  237. // 点击提交,检查名字是否重复,获取数据
  238. submit: function() {
  239. this.checkName();
  240. // if(!this.inforName){
  241. // alert('资料名称不能为空');
  242. // return false
  243. // }
  244. // if(!this.inforDes){
  245. // alert('资料描述不能为空');
  246. // return false
  247. // }
  248. // if(!this.inforName){
  249. // alert('资料名称不能为空');
  250. // return false
  251. // }
  252. if(!this.tipFlag){
  253. console.log(this.inforName);
  254. console.log(this.inforDes);
  255. console.log(this.materialTime);
  256. console.log(this.scope);
  257. console.log(this.tableData);
  258. const file = document.getElementById('fileInput').value;
  259. console.log(file);
  260. // console.log(document.getElementById('fileInput').files[0].name);
  261. }
  262. },
  263. // 接口请求
  264. submitRequest: function() {
  265. // this.$http({
  266. // method: 'post',
  267. // url: '/auth/checkSign',
  268. // data: {
  269. // token: token
  270. // }
  271. // }).then(() => {
  272. // console.log(res);
  273. // }).catch((err) => {
  274. // console.log(err);
  275. // })
  276. // console.log(this.inforName, this.inforDes, this.materialTime, this.scope, this.addByCustomize, File.size);
  277. // console.log(FileList.);
  278. },
  279. // 获取文件名
  280. getFileInfo: function() {
  281. this.fileDes = document.getElementById('fileInput').files[0].name
  282. console.log(this.fileDes);
  283. }
  284. }
  285. }
  286. </script>
  287. <style scoped lang="less">
  288. .upload_infor{
  289. form{
  290. border: 1px solid #ccc;
  291. padding: 10px;
  292. }
  293. .dataName{
  294. p{
  295. margin-left: 65px;
  296. font-size: 10px;
  297. color: rgb(206, 84, 84);
  298. }
  299. }
  300. .inforDes{
  301. margin: 10px 0 0 0;
  302. span{
  303. vertical-align: top;
  304. margin-right: 17px;
  305. }
  306. textarea{
  307. border: 1px solid #ccc;
  308. border-radius: 3px;
  309. color: #555555;
  310. font-size: 12px;
  311. }
  312. }
  313. .selectType{
  314. margin-top: 10px;
  315. margin-bottom: 10px;
  316. div{
  317. margin-left: 65px;
  318. }
  319. }
  320. .selectStyle{
  321. margin-left: 20px;
  322. margin-right: 20px;
  323. padding: 4px 6px;
  324. height: 28px;
  325. width: 144px;
  326. border: 1px solid #ccc;
  327. color: #555555;
  328. font-size: 12px;
  329. }
  330. .addByArea{
  331. margin: 10px 0 0 65px;
  332. display: flex;
  333. height: 28px;
  334. align-items: center;
  335. span{
  336. margin-right: 10px;
  337. }
  338. div{
  339. margin-right: 18px;
  340. height: 18px;
  341. input{
  342. width: 12px;
  343. height: 12px;
  344. vertical-align: middle;
  345. margin-top: -2px;
  346. border:1px solid #ccc
  347. }
  348. span{
  349. margin-left: 2px;
  350. height: 18px;
  351. line-height: 18px;
  352. }
  353. button{
  354. height: 28px;
  355. }
  356. }
  357. }
  358. .addByCustomize{
  359. margin: 10px 0 0 65px;
  360. button{
  361. height: 28px;
  362. }
  363. input{
  364. // background: url('../../img/search.svg') no-repeat center left;
  365. // background-size: 21px 25px;
  366. background-color: #fff;
  367. }
  368. }
  369. .addByGroup{
  370. margin: 10px 0 0 65px;
  371. display: flex;
  372. align-items: center;
  373. .selectBox{
  374. position: relative;
  375. margin-left: 17px;
  376. img{
  377. width: 144px;
  378. height: 28px;
  379. &:hover{
  380. cursor: pointer;
  381. }
  382. }
  383. .optionBox{
  384. position: absolute;
  385. top: 28px;
  386. left: 0;
  387. border: 1px solid #ccc;
  388. border-top: none;
  389. width: 142px;
  390. background-color: #fff;
  391. border-radius: 5px;
  392. ul{
  393. width: 144px;
  394. padding-bottom: 6px;
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. li{
  399. width: 132px;
  400. height: 28px;
  401. font-size: 12px;
  402. color: #555555;
  403. display: flex;
  404. align-items: center;
  405. border-bottom: 1px solid #ccc;
  406. display: flex;
  407. justify-content: space-between;
  408. padding-right: 5px;
  409. img{
  410. width: 20px;
  411. height: 20px;
  412. &:hover{
  413. cursor: pointer;
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. button{
  421. height: 28px;
  422. }
  423. }
  424. .table{
  425. margin-top: 10px;
  426. }
  427. .count{
  428. display: flex;
  429. justify-content: flex-end;
  430. }
  431. .uploadFile{
  432. display: flex;
  433. margin-top: 35px;
  434. height: 30px;
  435. align-items: center;
  436. p{
  437. margin-right: 20px;
  438. height: 20px;
  439. line-height: 20px;
  440. }
  441. .fileDes{
  442. width: 100px;
  443. overflow: hidden;
  444. overflow:hidden; /* 超出一行文字自动隐藏 */
  445. text-overflow:ellipsis;/* 文字隐藏后添加省略号 */
  446. white-space:nowrap; /* 强制不换行 */
  447. }
  448. label{
  449. height: 30px;
  450. line-height: 30px;
  451. width: 56px;
  452. background-color: #0056a0;
  453. color: #fff;
  454. text-align: center;
  455. font-size: 14px;
  456. input{
  457. display: none;
  458. }
  459. }
  460. }
  461. .submitBtn{
  462. margin-top: 50px;
  463. }
  464. }
  465. .inputStyle{
  466. margin-left: 17px;
  467. width: 130px;
  468. height: 18px;
  469. line-height: 18px;
  470. padding: 4px 6px;
  471. border: 1px solid #ccc;
  472. color: #555555;
  473. font-size: 12px;
  474. }
  475. .focusStyle{
  476. border: 1px solid #ccc;
  477. line-height: 20px;
  478. color: #555555;
  479. outline: none;
  480. }
  481. .focusStyle:focus{
  482. animation: shadowAni 200ms linear forwards;
  483. }
  484. @keyframes shadowAni{
  485. 0%{
  486. border-color: #cccccc;
  487. box-shadow: inset 0px 0px 0 #ccc;
  488. };
  489. 100%{
  490. border-color: #75b9F0;
  491. box-shadow: 0px 0px 10px #75b9F0;
  492. }
  493. }
  494. </style>