login_setting.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <div class="app-container">
  3. <div class="page-header">
  4. 轮播图管理
  5. </div>
  6. <el-divider></el-divider>
  7. <div class="btn-group">
  8. <el-button
  9. type="primary"
  10. size="small"
  11. @click="(dialogVisible = true), (type = 1)"
  12. >新增</el-button>
  13. <el-button size="small" type="danger" @click="batchDelete()">删除</el-button>
  14. </div>
  15. <div class="mymain-container">
  16. <el-table
  17. v-loading="listLoading"
  18. :data="dataList"
  19. element-loading-text="Loading"
  20. border
  21. fit
  22. highlight-current-row
  23. stripe
  24. @selection-change="handleSelectionChange"
  25. >
  26. <el-table-column type="selection" width="55" align="center">
  27. </el-table-column>
  28. <template v-for="col in columns">
  29. <el-table-column
  30. align="center"
  31. :label="col.lable"
  32. :prop="col.prop"
  33. :min-width="col.widht"
  34. show-overflow-tooltip
  35. v-if="col.prop == 'status'"
  36. >
  37. <template slot-scope="scope">
  38. <div style="z-index: 99">
  39. <el-tag type="success" v-if="scope.row.status == '1'" >显示</el-tag>
  40. <el-tag type="danger" v-else-if="scope.row.status == '0'">隐藏 </el-tag>
  41. </div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. align="center"
  46. :label="col.lable"
  47. :prop="col.prop"
  48. :min-width="col.widht"
  49. show-overflow-tooltip
  50. v-if="col.prop == 'imgCarouselUrl'"
  51. >
  52. <template slot-scope="scope">
  53. <a :href="scope.row.imgCarouselUrl" >
  54. <img :src="scope.row.imgCarouselUrl" alt="轮播图" class="el-image__inner el-image__preview"/>
  55. </a>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. v-else
  60. align="center"
  61. :label="col.lable"
  62. :prop="col.prop"
  63. :min-width="col.widht"
  64. show-overflow-tooltip
  65. >
  66. </el-table-column>
  67. </template>
  68. <el-table-column
  69. align="center"
  70. fixed="right"
  71. label="操作"
  72. min-width="160"
  73. >
  74. <template slot-scope="scope">
  75. <el-button type="text" size="small" @click="hanleEdit(scope.row)"
  76. >编辑</el-button
  77. >
  78. <el-button type="text" size="small" @click="hanleStatus(scope.row.id)" v-if="scope.row.status === '1'">隐藏</el-button>
  79. <el-button type="text" size="small" @click="hanleStatus(scope.row.id)" v-if="scope.row.status === '0'">显示</el-button>
  80. <el-popconfirm
  81. title="确定要删除这张轮播图吗?"
  82. style="margin-left: 10px"
  83. @onConfirm="hanleDelete(scope.row.id)"
  84. >
  85. <el-button slot="reference" type="text" size="small"
  86. >删除</el-button
  87. >
  88. </el-popconfirm>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <!-- 分页 -->
  93. <!-- <div style="margin: 20px 0">-->
  94. <!-- <el-pagination-->
  95. <!-- @size-change="handleSizeChange"-->
  96. <!-- @current-change="handleCurrentChange"-->
  97. <!-- :current-page="currentPage"-->
  98. <!-- :page-sizes="[10, 20, 30, 50]"-->
  99. <!-- :page-size="10"-->
  100. <!-- layout="total, sizes, prev, pager, next, jumper"-->
  101. <!-- :total="listTotal"-->
  102. <!-- >-->
  103. <!-- </el-pagination>-->
  104. <!-- </div>-->
  105. </div>
  106. <!-- 添加公司备案信息 -->
  107. <div>
  108. <div class="setting_title">备案管理</div>
  109. <el-divider></el-divider>
  110. <el-card shadow="never" class="my-card">
  111. <el-form
  112. class="my-form"
  113. ref="mainForm"
  114. :model="comPanyDialogForm"
  115. label-width="120px"
  116. label-position="right"
  117. >
  118. <el-form-item label="ICP备案:" prop="nickName">
  119. <el-input
  120. autocomplete="off"
  121. placeholder="请输入"
  122. v-model="comPanyDialogForm.icpRecord"
  123. ></el-input
  124. >
  125. </el-form-item>
  126. <el-form-item label="ICP备案链接:" prop="nickName">
  127. <el-input
  128. autocomplete="off"
  129. placeholder="请输入"
  130. v-model="comPanyDialogForm.icpRecordLink"
  131. ></el-input
  132. > (填写链接,可跳转至链接页面)
  133. </el-form-item>
  134. <el-form-item label="公网安备案:" prop="nickName">
  135. <el-input
  136. autocomplete="off"
  137. placeholder="请输入"
  138. v-model="comPanyDialogForm.pubSecurityRecord"
  139. ></el-input
  140. >
  141. </el-form-item>
  142. <el-form-item label="公网安备案链接:" prop="nickName">
  143. <el-input
  144. autocomplete="off"
  145. placeholder="请输入"
  146. v-model="comPanyDialogForm.pubSecurityRecordLink"
  147. ></el-input
  148. > (填写链接,可跳转至链接页面)
  149. </el-form-item>
  150. <div class="setting_title">公司名称管理</div>
  151. <el-divider></el-divider>
  152. <el-form-item label="公司名称:" prop="nickName">
  153. <el-input
  154. autocomplete="off"
  155. placeholder="单行输入"
  156. v-model="comPanyDialogForm.companyName"
  157. ></el-input
  158. >
  159. </el-form-item>
  160. </el-form>
  161. </el-card>
  162. </div>
  163. <div class="page-footer">
  164. <div class="footer">
  165. <!-- <el-button type="primary" @click="editFn">修改</el-button>-->
  166. <el-button type="primary" @click="addComPany">确定</el-button>
  167. </div>
  168. </div>
  169. <div>
  170. <el-dialog
  171. :visible.sync="dialogVisible"
  172. width="50%"
  173. @close="resetForm"
  174. :close-on-click-modal="false"
  175. >
  176. <el-form
  177. ref="dialogForm"
  178. :model="dialogForm"
  179. :rules="type == 1 ? rules : ''"
  180. label-width="120px"
  181. size="normal"
  182. >
  183. <el-form-item label="轮播图名称" prop="saleCode">
  184. <el-input v-model="dialogForm.imgCarouselName"></el-input>
  185. </el-form-item>
  186. <el-form-item label="轮播图" prop="fileUrl">
  187. <ImageUpload :fileList="fileList" :multiple="true" />
  188. </el-form-item>
  189. <el-form-item label="排序" prop="mainId">
  190. <el-input v-model="dialogForm.imgCarouselOrder"></el-input>
  191. </el-form-item>
  192. </el-form>
  193. <span slot="footer" class="dialog-footer">
  194. <el-button @click="(dialogVisible = false), resetForm()"
  195. >取 消</el-button
  196. >
  197. <el-button type="primary" @click="addImgCarousel">确 定</el-button>
  198. </span>
  199. </el-dialog>
  200. </div>
  201. </div>
  202. </template>
  203. <script>
  204. import Mixin from "@/mixin/index";
  205. import Pagination from "@/components/Pagination";
  206. import ImageUpload from '@/components/Common/image-upload.vue';
  207. import {
  208. getProductList,
  209. getImgCarouseList,
  210. handleImgIsShow,
  211. addImgCarousel,
  212. delImgData,
  213. addCompany,
  214. editImgCarousel,
  215. } from "@/api/policy_list";
  216. export default {
  217. mixins: [Mixin],
  218. data() {
  219. return {
  220. type: 0, // 0,1
  221. screenForm: {
  222. companyRecordManageId: "",
  223. imgCarouselName: "",
  224. imgCarouselUrl: "",
  225. imgCarouselOrder: "",
  226. status: "",
  227. },
  228. dialogForm: {
  229. id: "",
  230. companyRecordManageId: "",
  231. imgCarouselName: "",
  232. imgCarouselUrl: "",
  233. imgCarouselOrder: "",
  234. status: "1",
  235. },
  236. comPanyDialogForm: {
  237. id: "",
  238. icpRecord: "",
  239. icpRecordLink: "",
  240. pubSecurityRecord: "",
  241. pubSecurityRecordLink: "",
  242. companyName: "",
  243. },
  244. dataList: [
  245. {
  246. date: "2016-05-02",
  247. name: "王小虎",
  248. label: "姓名",
  249. address: "上海市普陀区金沙江路 1518 弄",
  250. },
  251. ],
  252. columns: [
  253. {
  254. prop: "imgCarouselName",
  255. lable: "轮播图名称",
  256. widht: 160,
  257. },
  258. {
  259. prop: "imgCarouselUrl",
  260. lable: "轮播图",
  261. widht: 160,
  262. },
  263. {
  264. prop: "imgCarouselOrder",
  265. lable: "排序",
  266. widht: 160,
  267. },
  268. {
  269. prop: "createTime",
  270. lable: "创建时间",
  271. widht: 160,
  272. },
  273. {
  274. prop: "status",
  275. lable: "状态",
  276. widht: 160,
  277. },
  278. ],
  279. rules: {
  280. imgCarouselName: [
  281. { required: true, message: "请输入轮播图名称", trigger: "blur" },
  282. ],
  283. // saleName: [
  284. // { required: true, message: "请输入销售类型名称", trigger: "blur" },
  285. // ],
  286. // mainName: [
  287. // { required: true, message: "请输入品类名称", trigger: "blur" },
  288. // ],
  289. },
  290. productList: [],
  291. fileList: [],
  292. multipleSelection: [],
  293. };
  294. },
  295. methods: {
  296. getList() {
  297. this.listLoading = true;
  298. const params = {
  299. pageNum: this.currentPage,
  300. pageSize: this.pageSize,
  301. saleCode: this.screenForm.saleCode,
  302. saleName: this.screenForm.saleName,
  303. mainId: "",
  304. status: this.screenForm.status,
  305. };
  306. // getTypeList(params).then((res) => {
  307. // this.dataList = res.data.records;
  308. // this.listTotal = res.data.total;
  309. // this.listLoading = false;
  310. // });
  311. getImgCarouseList(params).then((res) => {
  312. this.dataList = res.data;
  313. this.listLoading = false;
  314. });
  315. getProductList({
  316. productCategoryName: "",
  317. productCategoryNumber: "",
  318. }).then((res) => {
  319. this.productList = res.data;
  320. });
  321. },
  322. handleChange(e) {
  323. this.productList.find((k) => {
  324. if (k.productCategoryNumber == e) {
  325. this.dialogForm.mainId = k.productCategoryNumber;
  326. this.dialogForm.mainName = k.productCategoryName;
  327. this.screenForm.mainId = k.productCategoryNumber;
  328. this.screenForm.mainName = k.productCategoryName;
  329. }
  330. });
  331. },
  332. hanleDelete(id) {
  333. this.hanleDeleteAllPromise(id).then((ids) => {
  334. delImgData({
  335. ids: ids[0],
  336. }).then((res) => {
  337. this.$successMsg("删除成功");
  338. this.hanleReset();
  339. });
  340. });
  341. },
  342. hanleEdit(item) {
  343. this.dialogForm = {
  344. id: item.id,
  345. companyRecordManageId: item.companyRecordManageId,
  346. imgCarouselName: item.imgCarouselName,
  347. imgCarouselUrl: item.imgCarouselUrl,
  348. imgCarouselOrder: item.imgCarouselOrder,
  349. status: item.status,
  350. };
  351. this.type = 0;
  352. this.dialogVisible = true;
  353. },
  354. hanleDateil(item) {
  355. this.dialogVisible = true;
  356. this.dialogForm = {
  357. ...item,
  358. };
  359. this.type = 3;
  360. },
  361. hanleStatus(id){
  362. handleImgIsShow({
  363. id:id
  364. }).then((res) => {
  365. this.$successMsg("状态已更改");
  366. this.hanleReset();
  367. });
  368. },
  369. addImgCarousel(){
  370. if (this.type == 1) {
  371. this.$refs.dialogForm.validate((valid) => {
  372. //console.log(...this.dialogForm)
  373. if (valid) {
  374. this.dialogForm.imgCarouselUrl = "http://hg.zfire.top/api/img/get?key=" + this.fileList[0].url
  375. const params = {
  376. ...this.dialogForm,
  377. };
  378. addImgCarousel(params).then((res) => {
  379. this.$successMsg("添加成功");
  380. this.hanleReset();
  381. });
  382. } else {
  383. console.log("error submit!!");
  384. return false;
  385. }
  386. });
  387. } else if (this.type == 0) {
  388. const upParams = {
  389. ...this.dialogForm,
  390. };
  391. editImgCarousel(upParams).then((res) => {
  392. this.$successMsg("修改成功");
  393. this.hanleReset();
  394. });
  395. } else {
  396. this.dialogVisible = false;
  397. }
  398. },
  399. // 表格选择
  400. handleSelectionChange(val) {
  401. this.multipleSelection = val;
  402. },
  403. //添加公司信息
  404. addComPany(){
  405. const params = {
  406. ...this.comPanyDialogForm,
  407. };
  408. addCompany(params).then((res) => {
  409. this.$successMsg("添加成功");
  410. this.hanleReset();
  411. });
  412. },
  413. resetForm(formName) {
  414. this.$refs.dialogForm.resetFields();
  415. },
  416. hanleReset() {
  417. this.dialogForm = {
  418. companyRecordManageId: "",
  419. imgCarouselName: "",
  420. imgCarouselUrl: "",
  421. imgCarouselOrder: "",
  422. status: "1"
  423. };
  424. // this.$refs.dialogForm.resetFields()
  425. this.dialogVisible = false;
  426. this.getList();
  427. },
  428. batchDelete() {
  429. if(this.multipleSelection.length < 1) {
  430. return this.$errorMsg('请选择信息');
  431. }
  432. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  433. confirmButtonText: '确定',
  434. cancelButtonText: '取消',
  435. type: 'warning'
  436. }).then(() => {
  437. let ids = [];
  438. this.multipleSelection.forEach(item => {
  439. ids.push(item.id);
  440. });
  441. delImgData({ids: ids.join(',')}).then(res => {
  442. this.$successMsg('删除成功');
  443. this.hanleReset();
  444. })
  445. }).catch(() => {});
  446. },
  447. },
  448. components: {
  449. Pagination,
  450. ImageUpload
  451. },
  452. };
  453. </script>
  454. <style scoped>
  455. .el-switch.is-disabled {
  456. opacity: inherit;
  457. }
  458. .page-header{
  459. font-size: 18px;
  460. padding-bottom: 10px;
  461. font-weight: 600;
  462. }
  463. .cname-footer{
  464. margin-top: 15px;
  465. }
  466. .my-form{
  467. width :60%
  468. }
  469. </style>