index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <!-- -->
  2. <template>
  3. <div class='con' v-loading.fullscreen.lock="loading">
  4. <el-dialog title="企业信息" width="45%" :visible.sync="dialogFormVisible"><!--企业的详细信息窗口-->
  5. <el-form :model="form" :label-position="'left'" :label-width="formLabelWidth">
  6. <div class="con-main">
  7. <div class="d-l">
  8. <el-form-item label="信息标题:">
  9. <span>{{c_title}}</span>
  10. </el-form-item>
  11. <el-form-item label="联系人:">
  12. <span>{{c_user}}</span>
  13. </el-form-item>
  14. <el-form-item label="手机号:">
  15. <span>{{c_phone}}</span>
  16. </el-form-item>
  17. <el-form-item label="所属区域:">
  18. <span>{{c_area}}</span>
  19. </el-form-item>
  20. <el-form-item label="详细地址:">
  21. <span>{{c_address}}</span>
  22. </el-form-item>
  23. <el-form-item label="企业官网:">
  24. <span style="color:#0055f2;cursor:pointer" @click="fix_website(c_website)">{{c_website}}</span>
  25. </el-form-item>
  26. </div>
  27. <div class="d-r">
  28. <el-form-item label="企业LOGO:">
  29. <div class="c-logo"><img :src="c_logo" alt=""></div>
  30. </el-form-item>
  31. <el-form-item label="企业资质:">
  32. <div class="c-zizhi">
  33. <img :src="c_zizhi" alt="">
  34. <a v-if="$base.isImg(c_zizhi)" :href="c_zizhi" download="download" class="c-mask">
  35. <i class="iconfont icon-download"></i>
  36. </a>
  37. <div v-else class="c-mask">
  38. <i class="iconfont icon-download"></i>
  39. </div>
  40. </div>
  41. </el-form-item>
  42. </div>
  43. <el-form-item label="企业简介:">
  44. <div style="word-break: break-all">{{c_introduce}}</div>
  45. </el-form-item>
  46. </div>
  47. </el-form>
  48. <div style="text-align:center" class="dialog-footer">
  49. <div v-if="c_state === 0">
  50. <el-button type="danger" @click="save(c_id,2)">拒 绝</el-button>
  51. <el-button type="primary" @click="save(c_id,1)">通 过</el-button>
  52. </div>
  53. <el-button type="info" v-else>{{c_state===1?'已通过':'已拒绝'}}</el-button>
  54. </div>
  55. </el-dialog>
  56. <el-dialog title="新增企业" width="45%" :visible.sync="dialogAddCpnyVisible">
  57. <el-form :model="form" :label-position="'left'" :label-width="formLabelWidth">
  58. <div style="padding:0 30px">
  59. <div class="add-l">
  60. <el-form-item label="*企业名称">
  61. <el-input show-word-limit maxlength="20" v-model="ac_name"></el-input>
  62. </el-form-item>
  63. <el-form-item label="*所属区域">
  64. <!--<el-input v-model="ac_belongArea" placeholder="请以一个空格为间隔,如“XX省 XX市 XX区”" rows="2" type="textarea" resize="none"></el-input>-->
  65. <el-input v-model="ac_add_province" style="width:25%"></el-input><span>省</span>
  66. <el-input v-model="ac_add_city" style="width:25%"></el-input><span>市</span>
  67. <el-input v-model="ac_add_area" style="width:25%"></el-input><span>区</span>
  68. </el-form-item>
  69. <el-form-item label="*详细地址">
  70. <el-input show-word-limit maxlength="50" v-model="ac_address"></el-input>
  71. </el-form-item>
  72. <el-form-item label="*企业LOGO">
  73. <el-upload
  74. :headers="{token}"
  75. :action="serverName+'/company/uploadLogo'"
  76. :show-file-list="true"
  77. :before-upload="beforeAvatarUpload"
  78. :on-change="handleChange"
  79. :file-list="fileList"
  80. :on-success="upload_success"
  81. :on-error="upload_fail">
  82. <div class="zfb-load">
  83. <el-button style="float:left;" size="small" type="primary">点击上传</el-button>
  84. <div style="font-size:10px;float:left;" slot="tip">1.支持png、jpg和gif图片格式;</div>
  85. <div style="font-size:10px;float:left;" slot="tip">2.最多可上传1张图;</div>
  86. <div style="font-size:10px;float:left;" slot="tip">3.最大可上传10M的图片。</div>
  87. </div>
  88. </el-upload>
  89. </el-form-item>
  90. <el-form-item label="企业简介">
  91. <el-input type="textarea" resize="none" rows="9" show-word-limit maxlength="100" v-model="ac_introduce"></el-input>
  92. </el-form-item>
  93. </div>
  94. <div class="add-r">
  95. <el-form-item label="*联系人">
  96. <el-input show-word-limit maxlength="20" v-model="ac_user"></el-input>
  97. </el-form-item>
  98. <el-form-item label="*手机号">
  99. <el-input v-model="ac_phone"></el-input>
  100. </el-form-item>
  101. <el-form-item label="企业官网">
  102. <el-input v-model="ac_website" rows="2" type="textarea" resize="none"></el-input>
  103. </el-form-item>
  104. <el-form-item label="*企业资质">
  105. <el-upload
  106. :action="serverName+'/company/uploadLogo'"
  107. :show-file-list="true"
  108. :before-upload="beforeAvatarUpload"
  109. :on-change="handleChange"
  110. :file-list="fileList2"
  111. :on-success="upload_success"
  112. :on-error="upload_fail">
  113. <div class="zfb-load">
  114. <el-button style="float:left" size="small" type="primary">点击上传</el-button>
  115. <div style="font-size:10px;float:left;" slot="tip">1.支持png、jpg和gif图片格式;</div>
  116. <div style="font-size:10px;float:left;" slot="tip">2.最多可上传1张图;</div>
  117. <div style="font-size:10px;float:left;" slot="tip">3.最大可上传10M的图片。</div>
  118. </div>
  119. </el-upload>
  120. </el-form-item>
  121. </div>
  122. </div>
  123. </el-form>
  124. <div style="text-align:center" class="dialog-footer">
  125. <div>
  126. <el-button @click="dialogAddCpnyVisible = false">取 消</el-button>
  127. <el-button type="primary" @click="addCompany()">提 交</el-button>
  128. </div>
  129. </div>
  130. </el-dialog>
  131. <div class="h-header"><!--企业认证的头部内容-->
  132. <vcenter>
  133. <div>
  134. <el-dropdown>
  135. <el-button type="primary">
  136. {{dropdown_active.text}}
  137. <i class="el-icon-arrow-down el-icon--right"></i>
  138. </el-button>
  139. <el-dropdown-menu slot="dropdown">
  140. <el-dropdown-item style="padding:0" v-for="(item,i) in dropdown_actives" :key="i">
  141. <div style="padding:0 20px;" @click="dropdown_active=item">{{item.text}}</div>
  142. </el-dropdown-item>
  143. </el-dropdown-menu>
  144. </el-dropdown>
  145. </div>
  146. <div class="h-input">
  147. <span>时间段:</span>
  148. </div>
  149. <div class="fix-date">
  150. <el-date-picker v-model="value5" type="datetimerange" :picker-options="pickerOptions2" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd hh:mm:ss" align="right">
  151. </el-date-picker>
  152. </div>
  153. <div class="h-input"><span>手机号:</span></div>
  154. <div>
  155. <el-input v-model="userName" placeholder="输入手机号查询"></el-input>
  156. </div>
  157. <div>
  158. <el-button @click="refresh" type="primary">搜索</el-button>
  159. </div>
  160. <div style="float:right;padding-right:20px">
  161. <el-button @click="showAdd" type="primary">新增企业</el-button>
  162. </div>
  163. </vcenter>
  164. </div>
  165. <div class="h-body">
  166. <el-table height="520" :data="tableData" style="width: 100%;padding:0 20px;">
  167. <el-table-column v-for="(item,i) in tableHeader" :key="i" :prop="item.name" :label="item.label"><!--企业认证表格前三个标题:提交日期、企业名称、手机号-->
  168. </el-table-column>
  169. <el-table-column label="状态">
  170. <template slot-scope="scope">
  171. <span :class="scope.row.state.class">{{scope.row.state.text}}</span>
  172. </template>
  173. </el-table-column>
  174. <el-table-column label="操作">
  175. <template slot-scope="scope">
  176. <span class="o-span" @click="show(scope.row)">详细信息</span>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. <div class="p-con">
  181. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="size" layout="prev, pager, next, jumper" :total="total">
  182. </el-pagination>
  183. </div>
  184. </div>
  185. </div>
  186. </template>
  187. <script>
  188. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  189. // 例如:import 《组件名称》 from '《组件路径》';
  190. import vcenter from '@/components/vcenter'
  191. import {
  192. serverName
  193. } from '@/utils/http'
  194. const tableHeader = [{
  195. name: 'createTime',
  196. label: '提交日期'
  197. }, {
  198. name: 'name',
  199. label: '企业名称'
  200. }, {
  201. name: 'userName',
  202. label: '手机号'
  203. }]
  204. export default {
  205. // import引入的组件需要注入到对象中才能使用
  206. components: {
  207. vcenter
  208. },
  209. data () {
  210. // 这里存放数据
  211. return {
  212. dropdown_actives: [{
  213. text: '全部',
  214. id: ''
  215. },
  216. {
  217. text: '已通过',
  218. id: 1
  219. },
  220. {
  221. text: '审核中',
  222. id: 0
  223. },
  224. {
  225. text: '已拒绝',
  226. id: 2
  227. }
  228. ],
  229. dropdown_active: {
  230. text: '全部',
  231. id: ''
  232. },
  233. serverName,
  234. fileList:[],
  235. fileList2:[],
  236. tableData: [],
  237. tableHeader,
  238. dialogFormVisible: false,
  239. dialogAddCpnyVisible: false,
  240. currentPage: 1,
  241. value3: true,
  242. loading: false,
  243. formLabelWidth: '100px',
  244. userName: '',
  245. form: {},
  246. size: 10,
  247. total: 0,
  248. c_id: '',
  249. c_title: '',
  250. c_user: '',
  251. c_phone: '',
  252. c_area: '',
  253. c_address: '',
  254. c_website: '',
  255. c_introduce: '',
  256. c_logo: '',
  257. c_zizhi: '',
  258. c_state: '',
  259. inpuKey: '',
  260. ac_name:'',
  261. ac_belongArea:'',
  262. ac_add_province:'',
  263. ac_add_city:'',
  264. ac_add_area:'',
  265. ac_address:'',
  266. ac_logo:'',
  267. ac_introduce:'',
  268. ac_user:'',
  269. ac_phone:'',
  270. ac_website:'',
  271. ac_zizhi:'',
  272. pickerOptions2: { //:picker-options="pickerOptions2"
  273. shortcuts: [{
  274. text: '最近一周',
  275. onClick (picker) {
  276. const end = new Date()//声明只读Date类型变量,此时end和start为当前时间
  277. const start = new Date()
  278. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)//start的时间设为距离现在一周前的日期
  279. picker.$emit('pick', [start, end])
  280. }
  281. }, {
  282. text: '最近一个月',
  283. onClick (picker) {
  284. const end = new Date()
  285. const start = new Date()
  286. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)//start的时间设为距离现在一个月前的日期
  287. picker.$emit('pick', [start, end])
  288. }
  289. }, {
  290. text: '最近三个月',
  291. onClick (picker) {
  292. const end = new Date()
  293. const start = new Date()
  294. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)//start的时间设为距离现在三个月前的日期
  295. picker.$emit('pick', [start, end])
  296. }
  297. }]
  298. },
  299. value5: []
  300. }
  301. },
  302. // 监听属性 类似于data概念
  303. computed: {
  304. token () {
  305. return window.localStorage.getItem('zfb_token')
  306. }
  307. },
  308. // 监控data中的数据变化
  309. watch: {
  310. currentPage () {
  311. this.refresh()
  312. },
  313. size () {
  314. this.refresh()
  315. }
  316. },
  317. // 方法集合
  318. methods: {
  319. fix_website (value) { //value值如有“https://”的话在新窗口打开value存的地址,没有的话添加前缀名后再打开
  320. if (this.$base.isContain(value, 'http://') || this.$base.isContain(value, 'https://')) {
  321. window.open(value, '_blank')
  322. } else {
  323. window.open('http://' + value, '_blank')
  324. }
  325. },
  326. handleSizeChange (val) {
  327. console.log(`每页 ${val} 条`)
  328. },
  329. handleCurrentChange (val) {
  330. console.log(`当前页: ${val}`)
  331. },
  332. refresh () { //重新加载数据
  333. this.loading = true
  334. this.getData()
  335. this.loading = false
  336. },
  337. clearInfo () {
  338. this.dialogFormVisible = false //隐藏弹窗
  339. this.$bus.$emit('refresh', true) //触发当前实例上的refresh()
  340. this.refresh()
  341. },
  342. async save (id = '', state = '') {
  343. await this.$http({
  344. method: 'post',
  345. data: {
  346. id,
  347. state
  348. },
  349. url: '/company/auditCompany',
  350. headers: {
  351. token: window.localStorage.getItem('zfb_token')
  352. }
  353. }).then(res => {
  354. if (res.code === 200) {
  355. this.$alert('审核成功!', {
  356. confirmButtonText: '确定',
  357. callback: action => {
  358. this.clearInfo()
  359. }
  360. })
  361. } else {
  362. this.$notify.error({
  363. title: '错误',
  364. message: res.message
  365. })
  366. }
  367. })
  368. },
  369. async getData () {
  370. let params = {
  371. userName: this.userName || '',
  372. startTime: this.value5 ? this.value5[0] : '',
  373. endTime: this.value5 ? this.value5[1] : '',
  374. state: this.dropdown_active.id !== '' ? this.dropdown_active.id : ''
  375. }
  376. let result = await this.$http({
  377. method: 'post',
  378. data: params,
  379. url: '/company/selectCompanyByType',
  380. headers: {
  381. token: window.localStorage.getItem('zfb_token'),
  382. pageNum: this.currentPage,
  383. pageSize: this.size
  384. }
  385. })
  386. for (let i = 0; i < result.message.list.length; i++) {
  387. result.message.list[i].createTime = this.$base.dateFormat('yyyy-MM-dd hh:mm', new Date(result.message.list[i].createTime))
  388. result.message.list[i].state = this.fixState(result.message.list[i].state)
  389. }
  390. this.tableData = result.message.list
  391. this.total = result.message.total
  392. this.currentPage = result.message.pageNum
  393. },
  394. async show (item) {
  395. this.dialogFormVisible = true
  396. let result = await this.$http({
  397. method: 'post',
  398. data: {
  399. id: item.id
  400. },
  401. url: '/company/selectCompanyById',
  402. headers: {
  403. token: window.localStorage.getItem('zfb_token')
  404. }
  405. })
  406. let list = result.message
  407. this.c_id = list.id || ''
  408. this.c_title = list.name || ''
  409. this.c_user = list.contacts || ''
  410. this.c_phone = list.phone || ''
  411. this.c_area = list.area || ''
  412. this.c_address = list.address || ''
  413. this.c_website = list.website || ''
  414. this.c_logo = list.logo || ''
  415. this.c_zizhi = list.qualification || ''
  416. this.c_introduce = list.introduce || ''
  417. this.c_state = list.state
  418. },
  419. fixState (state) { //通过state值返回一个obj对象表示审核状态,内容有status,文本text,选择器名class
  420. let obj = {}
  421. switch (state) {
  422. case 0:
  423. obj = {
  424. status: 0,
  425. text: '审核中',
  426. class: 'zfb-shenhe'
  427. }
  428. break
  429. case 1:
  430. obj = {
  431. status: 1,
  432. text: '已通过',
  433. class: 'zfb-success'
  434. }
  435. break
  436. case 2:
  437. obj = {
  438. status: 2,
  439. text: '已拒绝',
  440. class: 'zfb-reject'
  441. }
  442. break
  443. default:
  444. break
  445. }
  446. return obj
  447. },
  448. beforeAvatarUpload (file) {
  449. const isLt10M = file.size / 1024 / 1024 < 10
  450. if (!isLt10M) {
  451. this.$message.error('上传图片大小不能超过 10MB!')
  452. return false
  453. }
  454. const isFormat = file.type === 'image/jpg' || file.type === 'image/png' || file.type === 'image/gif'
  455. if (!isFormat) {
  456. this.$message.error('上传图片格式错误!')
  457. return false
  458. }
  459. return isLt10M && isFormat
  460. },
  461. showAdd(){
  462. this.dialogAddCpnyVisible = !this.dialogAddCpnyVisible
  463. },
  464. handleChange (file, fileList) {
  465. console.log('file', file)
  466. console.log('fileList', fileList)
  467. if (fileList.length > 1) {
  468. this.fileList = fileList.slice(-1)
  469. }
  470. },
  471. upload_success (data) {
  472. console.log('上传成功')
  473. this.homepic = data.message
  474. },
  475. upload_fail (data) {
  476. this.$notify.error({
  477. title: '上传失败',
  478. message: data.message
  479. })
  480. },
  481. //新增企业
  482. addCompany(){
  483. let params = {
  484. name: this.ac_name,
  485. area: this.ac_add_province + '省 ' + this.ac_add_city + '市 ' + this.ac_add_area + '区',
  486. address: this.ac_address,
  487. logo: this.ac_logo,
  488. introduce: this.ac_introduce,
  489. contacts: this.ac_user,
  490. phone: this.ac_phone,
  491. website: this.ac_website,
  492. qualification: this.ac_zizhi
  493. }
  494. this.$http({
  495. method: 'post',
  496. data: params,
  497. url: '/company/back/save',
  498. headers: {
  499. token: window.localStorage.getItem('zfb_token')
  500. }
  501. }).then(res =>{
  502. if(res.code === 200){
  503. this.$alert('新增成功', '提示', {
  504. confirmButtonText: '确定',
  505. callback: action => {
  506. this.dialogAddCpnyVisible = false
  507. this.clearInfo()
  508. this.refresh()
  509. }
  510. })
  511. }else{
  512. this.$notify.error({
  513. title:'错误',
  514. message:res.message
  515. })
  516. }
  517. })
  518. }
  519. },
  520. // 生命周期 - 创建完成(可以访问当前this实例)
  521. created () {
  522. },
  523. // 生命周期 - 挂载完成(可以访问DOM元素)
  524. mounted () {
  525. this.refresh()
  526. },
  527. beforeCreate () {}, // 生命周期 - 创建之前
  528. beforeMount () {}, // 生命周期 - 挂载之前
  529. beforeUpdate () {}, // 生命周期 - 更新之前
  530. updated () {}, // 生命周期 - 更新之后
  531. beforeDestroy () {}, // 生命周期 - 销毁之前
  532. destroyed () {}, // 生命周期 - 销毁完成
  533. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  534. }
  535. </script>
  536. <style lang="scss" scoped>
  537. .con {
  538. .con-main {
  539. padding: 0 30px;
  540. .d-l {
  541. display: inline-block
  542. }
  543. .d-r {
  544. float: right;
  545. .c-logo {
  546. width: 150px;
  547. height: 150px;
  548. border: 1px solid #ccc;
  549. border-radius: 4px;
  550. background-color: #f5fafe;
  551. img {
  552. width: 100%;
  553. height: 100%;
  554. }
  555. }
  556. .c-zizhi {
  557. width: 150px;
  558. height: 150px;
  559. border: 1px solid #ccc;
  560. border-radius: 4px;
  561. position: relative;
  562. background-color: #f5fafe;
  563. img {
  564. width: 100%;
  565. height: 100%;
  566. }
  567. .c-mask {
  568. width: 100%;
  569. height: 100%;
  570. position: absolute;
  571. top: 0;
  572. left: 0;
  573. background: rgba(0, 0, 0, 0.5);
  574. text-align: center;
  575. display: table;
  576. .icon-download {
  577. text-align: center;
  578. display: table-cell;
  579. vertical-align: middle;
  580. color: #fff;
  581. font-size: 20px;
  582. }
  583. }
  584. }
  585. }
  586. }
  587. .add-l{
  588. display: inline-block;
  589. width:45%;
  590. }
  591. .add-r{
  592. width:45%;
  593. float: right;
  594. }
  595. .ei-num {
  596. .el-input-number {
  597. width: 90%;
  598. }
  599. }
  600. .ei-input {
  601. width: 100%;
  602. max-height: 200px;
  603. overflow-y: auto;
  604. .input-con {
  605. display: inline-block;
  606. width: 45%;
  607. margin: 2px 5px 2px 0;
  608. height: 60px;
  609. position: relative;
  610. .el-input_err {
  611. & /deep/ .el-input__inner {
  612. border: 1px solid #f56c6c;
  613. }
  614. }
  615. .el-input_success {
  616. & /deep/ .el-input__inner {
  617. border: 1px solid #67c23a;
  618. }
  619. }
  620. span {
  621. color: #f56c6c;
  622. font-size: 12px;
  623. line-height: 1;
  624. padding-top: 4px;
  625. position: absolute;
  626. left: 0;
  627. }
  628. }
  629. }
  630. .h-header {
  631. height: 80px;
  632. background-color: #fff;
  633. padding-left: 20px;
  634. box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
  635. border-radius: 3px;
  636. div {
  637. display: inline-block;
  638. vertical-align: middle;
  639. }
  640. .h-input {
  641. margin-left: 20px;
  642. display: inline-block;
  643. }
  644. .fix-date {
  645. div {
  646. display: flex;
  647. }
  648. }
  649. }
  650. .h-body {
  651. width: 100%;
  652. margin: 30px 0 0;
  653. padding-top: 20px;
  654. box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
  655. border-radius: 3px;
  656. background-color: #fff;
  657. .o-span {
  658. color: #0175dc;
  659. cursor: pointer;
  660. }
  661. .p-con {
  662. width: 100%;
  663. text-align: right;
  664. padding: 25px 20px 30px;
  665. }
  666. }
  667. }
  668. </style>