|
|
@@ -0,0 +1,318 @@
|
|
|
+<template>
|
|
|
+ <div class="app-content" @click="globalClick">
|
|
|
+ <!-- list -->
|
|
|
+ <div class="list-wrap">
|
|
|
+ <block v-if="!$util.isEmpty(list.data)">
|
|
|
+ <div class="list" v-for="(item, index) in list.data" :key="index">
|
|
|
+ <div class="list-index">{{ item.id }}</div>
|
|
|
+ <div class="list-img">
|
|
|
+ <img :src="`${constant.imgUrl}/hhb_small.png`" alt="" mode="widthFix" style="width:120rpx"/>
|
|
|
+ </div>
|
|
|
+ <div class="list-det">
|
|
|
+ <div class="app-size-28 app-color-0">{{ item.name || '' }}</div>
|
|
|
+
|
|
|
+ <div class="list-operate">
|
|
|
+ <div class="operate-det">
|
|
|
+ <span>花材数:{{ item.num }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="operate-icon-wrap" @click.stop="operateFn(item, index, $event)">
|
|
|
+ <div class="operate-icon">
|
|
|
+ <i class="iconfont" :class="[ index == operateIndex ? 'iconcaozuojihuo' : 'iconcaozuo']" style="font-size:38rpx;"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- operate -->
|
|
|
+ <operate-module
|
|
|
+ v-if="operateShow"
|
|
|
+ :top="operateTop"
|
|
|
+ :right="30"
|
|
|
+ @clickFn="operateList"
|
|
|
+ :btnData="btnData" />
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
|
|
|
+ </block>
|
|
|
+ </div>
|
|
|
+ <!-- button -->
|
|
|
+ <div class="app-footer">
|
|
|
+ <button class="admin-button-com middle blue" @click="addCategoryFn">添加分类</button>
|
|
|
+ </div>
|
|
|
+ <!-- modify -->
|
|
|
+ <modal-module :show="modifyModal" :maskClosable="false" @cancel="modalCancel" @click="replaceModalClick" width="92%" :title="modifyTitle" padding="30rpx 30rpx">
|
|
|
+ <template v-slot:content>
|
|
|
+ <div class="app-modal-input-wrap modify-modal">
|
|
|
+ <div class="inp-list-line">
|
|
|
+ <div class="line-label">名称</div>
|
|
|
+ <div class="line-input">
|
|
|
+ <input type="text" v-model="replaceForm.name" :adjust-position="false" class="inp-input" placeholder="请填写" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="inp-list-line">
|
|
|
+ <div class="line-label">顺序</div>
|
|
|
+ <div class="line-input">
|
|
|
+ <input type="text" v-model="replaceForm.inTurn" :adjust-position="false" class="inp-input" placeholder="越大越靠前" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </modal-module>
|
|
|
+ <!-- 删除提示 -->
|
|
|
+ <modal-module :show="delModal" :maskClosable="false" @cancel="modalCancel" @click="delModalClick" content="确定删除?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import ModalModule from '@/components/plugin/modal'
|
|
|
+import AppUploader from '@/components/app-uploader'
|
|
|
+import OperateModule from '@/admin/home/components/module/operate'
|
|
|
+import AppWrapperEmpty from '@/components/app-wrapper-empty'
|
|
|
+import { list } from '@/mixins'
|
|
|
+import { getList,addClass,updateClass} from '@/api/item-class'
|
|
|
+export default {
|
|
|
+ name: 'category-manage',
|
|
|
+ components: {
|
|
|
+ ModalModule,
|
|
|
+ AppUploader,
|
|
|
+ OperateModule,
|
|
|
+ AppWrapperEmpty
|
|
|
+ },
|
|
|
+ mixins: [list],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ modifyModal: false,
|
|
|
+ modifyTitle: '添加',
|
|
|
+ replaceForm: {
|
|
|
+ name: '',
|
|
|
+ id:0,
|
|
|
+ inTurn: 100
|
|
|
+ },
|
|
|
+ delModal: false,
|
|
|
+ operateShow: false,
|
|
|
+ operateData: {},
|
|
|
+ operateIndex: null,
|
|
|
+ operateTop: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ btnData() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ text: '编辑',
|
|
|
+ icon: 'iconbianji',
|
|
|
+ click: () => {
|
|
|
+ this.modifyModal = true
|
|
|
+ this.modifyTitle = '编辑'
|
|
|
+ this.modifyForm = {
|
|
|
+ name: this.operateData.name,
|
|
|
+ id: this.operateData.id,
|
|
|
+ inTurn: this.operateData.inTurn
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '删除',
|
|
|
+ icon: 'iconshanchu1',
|
|
|
+ click: () => {
|
|
|
+ this.delModal = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onPullDownRefresh() {
|
|
|
+ this.resetList()
|
|
|
+ this._list().then(res => {
|
|
|
+ uni.stopPullDownRefresh()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onReachBottom() {
|
|
|
+ if (!this.list.finished) {
|
|
|
+ this._list().then(res => {
|
|
|
+ uni.stopPullDownRefresh()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.stopPullDownRefresh()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ operateList(index){
|
|
|
+ if(index === 0){
|
|
|
+ this.modifyModal = true
|
|
|
+ this.modifyTitle = '编辑'
|
|
|
+ this.replaceForm = {
|
|
|
+ id:this.operateData.id,
|
|
|
+ name: this.operateData.name,
|
|
|
+ inTurn: this.operateData.inTurn,
|
|
|
+ }
|
|
|
+ }else if(index === 1) {
|
|
|
+ this.delModal = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async init() {
|
|
|
+ this._list()
|
|
|
+ },
|
|
|
+ _list() {
|
|
|
+ return getList().then(res => {
|
|
|
+ this.completes(res)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ replaceClass() {
|
|
|
+ if (!this.replaceForm.name) {
|
|
|
+ this.$msg('请填写分类名称')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let host = this.replaceForm.id == 0 ? addClass : updateClass;
|
|
|
+ let form = JSON.parse(JSON.stringify(this.replaceForm))
|
|
|
+ host({
|
|
|
+ ...form
|
|
|
+ }).then(res => {
|
|
|
+ this.$msg('操作成功!')
|
|
|
+ this.modalCancel()
|
|
|
+ this.operateCancle()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.resetList()
|
|
|
+ this._list()
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addCategoryFn() {
|
|
|
+ this.resetForm()
|
|
|
+ this.modifyModal = true
|
|
|
+ this.modifyTitle = '新增'
|
|
|
+ },
|
|
|
+ resetForm() {
|
|
|
+ this.replaceForm = {
|
|
|
+ name: '',
|
|
|
+ inTurn: 0,
|
|
|
+ id:0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ replaceModalClick(e) {
|
|
|
+ if (e.index === 0) {
|
|
|
+ this.modalCancel()
|
|
|
+ } else {
|
|
|
+ this.replaceClass()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ modalCancel() {
|
|
|
+ this.delModal = false
|
|
|
+ this.modifyModal = false
|
|
|
+ },
|
|
|
+ switchChangeFn(e) {
|
|
|
+ this.replaceForm.status = e.detail.value ? 1 : 0
|
|
|
+ },
|
|
|
+ delModalClick(e) {
|
|
|
+ if (e.index === 0) {
|
|
|
+ this.modalCancel()
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '开发中',
|
|
|
+ duration: 2000,
|
|
|
+ icon:'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ operateFn(item, index, event) {
|
|
|
+ this.operateData = item
|
|
|
+ this.operateIndex = index
|
|
|
+ this.operateShow = true
|
|
|
+ this.operateTop = event.currentTarget.offsetTop
|
|
|
+ },
|
|
|
+ operateCancle() {
|
|
|
+ this.operateData = {}
|
|
|
+ this.operateIndex = null
|
|
|
+ this.operateShow = false
|
|
|
+ },
|
|
|
+ //点击页面取消
|
|
|
+ globalClick(){
|
|
|
+ this.operateCancle()
|
|
|
+ },
|
|
|
+ changeStatusFn() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '开发中',
|
|
|
+ duration: 2000,
|
|
|
+ icon:'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .app-content {
|
|
|
+ min-height: calc(100vh - 100px);
|
|
|
+ padding-bottom: 100px;
|
|
|
+ }
|
|
|
+ // list
|
|
|
+ .list-wrap {
|
|
|
+ position: relative;
|
|
|
+ background-color: #fff;
|
|
|
+ .list {
|
|
|
+ height: 130px;
|
|
|
+ @include disFlex(center, flex-start);
|
|
|
+ padding: 80rpx 0 80rpx 0;
|
|
|
+ margin: 0 30px;
|
|
|
+ color: $fontColor3;
|
|
|
+ border-bottom: 1px solid $borderColor;
|
|
|
+ .list-index {
|
|
|
+ width: 50px;
|
|
|
+ }
|
|
|
+ .list-img {
|
|
|
+ width: 130px;
|
|
|
+ height: 130px;
|
|
|
+ img {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .list-det {
|
|
|
+ width: calc(100% - 200px);
|
|
|
+ margin-left: 20px;
|
|
|
+ & > div {
|
|
|
+ margin-top: 14px;
|
|
|
+ &:first-child {
|
|
|
+ margin-top: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .list-operate {
|
|
|
+ @include disFlex(center, space-between);
|
|
|
+ .operate-det {
|
|
|
+ & > span {
|
|
|
+ margin-left: 60px;
|
|
|
+ &:first-child {
|
|
|
+ margin-left: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .app-footer {
|
|
|
+ justify-content: flex-end;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 200px;
|
|
|
+ margin-right: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 编辑弹窗
|
|
|
+ .modify-modal {
|
|
|
+ .prompt-text {
|
|
|
+ color: red;
|
|
|
+ position: relative;
|
|
|
+ right: 52px;
|
|
|
+ bottom: 24px;
|
|
|
+ // margin-bottom: 10px;
|
|
|
+ }
|
|
|
+ .line-label {
|
|
|
+ width: 140px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+ .switch-wrap {
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|