|
@@ -5,7 +5,14 @@
|
|
|
<div class="discountCodeBox flex-col">
|
|
|
<van-list v-model:loading="loading" v-model:error="error" :error-text="$t('public.requestFailed')"
|
|
|
:finished="finished" :finished-text="$t('public.noMore')" offset="300" :immediate-check="false" @load="onLoad">
|
|
|
- <div class="searchRow flex-row justify-between">
|
|
|
+ <div v-if="isDelete" class="searchRow flex-row justify-between">
|
|
|
+ <div class="l-flex-RC c-text-15 c-text-color c-text-b">
|
|
|
+ {{ $t("advertManage.advertRule.selected") }}
|
|
|
+ {{ selectTotals }}
|
|
|
+ {{ $t("advertManage.advertRule.individual") }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-else class="searchRow flex-row justify-between">
|
|
|
<div class="flex-col">
|
|
|
<div class="flex-row justify-between bd3">
|
|
|
<div class="flex-col outer4"></div>
|
|
@@ -16,40 +23,89 @@
|
|
|
<div class="flex-col">
|
|
|
<div class="main5 flex-row justify-between" @click="searchClick">
|
|
|
<img class="label2" src="../../assets/device/searchIcon.png" />
|
|
|
- <div class="TextGroup2 flex-col">
|
|
|
- <span class="txt3">{{ $t('discountCode.search') }}</span>
|
|
|
- </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="tabButtomBox flex-row">
|
|
|
<div class="tabBox flex-row">
|
|
|
- <span :class="{ active: isUse === '0' }" @click="setIsUse('0')">{{ $t('discountCode.notUsed') }}</span>
|
|
|
- <span :class="{ active: isUse === '1' }" @click="setIsUse('1')">{{ $t('discountCode.used') }}</span>
|
|
|
+ <span :class="{ active: isUse === '0' }" @click="setIsUse('0')" style="cursor: pointer;">{{
|
|
|
+ $t('discountCode.notUsed') }}</span>
|
|
|
+ <span :class="{ active: isUse === '1' }" @click="setIsUse('1')" style="cursor: pointer;">{{
|
|
|
+ $t('discountCode.used') }}</span>
|
|
|
+ </div>
|
|
|
+ <div v-if="isDelete" class="buttomBox flex-row">
|
|
|
+ <div @click="cancelClk" class="buttonItem" style="color: #9696b1;">
|
|
|
+ {{ $t("discountCode.cancel") }}
|
|
|
+ </div>
|
|
|
+ <div @click="allClk" class="buttonItem" style="color: #4b6ad1">
|
|
|
+ {{ $t("discountCode.selectAll") }}
|
|
|
+ </div>
|
|
|
+ <div @click="noticeClk" class="buttonItem" style="color: #df5e4c">
|
|
|
+ {{ $t("discountCode.confirmDel") }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="buttomBox flex-row">
|
|
|
- <div class="buttonItem" @click="exportClick()">{{ $t('discountCode.export') }}></div>
|
|
|
- <div class="buttonItem" @click="payCode()">{{ $t('discountCode.apply') }}></div>
|
|
|
+ <div v-else class="buttomBox flex-row">
|
|
|
+ <div class="buttonItem" @click="payCode()" style="color: #4b6ad1">{{ $t('discountCode.apply') }}</div>
|
|
|
+ <div class="buttonItem" @click="isDelete = true">{{ $t('discountCode.delete') }}</div>
|
|
|
+ <div class="buttonItem" @click="exportClick()" style="color: #45be2d">{{ $t('discountCode.export') }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="intervalRow"></div>
|
|
|
<div class="listBox">
|
|
|
<div v-for="(item, index) in discountCodeList" :key="index" class="listItem" @click="disCountCodeClick(item)">
|
|
|
<div class="itemBox">
|
|
|
- <div class="itemRow"><span class="itemTitle">{{ $t('discountCode.discountCode') }}: </span>{{ item.code
|
|
|
- }}<span class="itemTitle discount">{{ item.type == '1' ? $t('discountCode.deduction') : $t('discountCode.discount') }}: </span>{{ item.discount }}
|
|
|
+ <div class="itemRow">
|
|
|
+ <span class="itemTitle">
|
|
|
+ {{ $t('discountCode.discountCode') }}:
|
|
|
+ </span>
|
|
|
+ {{ item.code }}
|
|
|
+ <span class="itemTitle discount">
|
|
|
+ {{ item.type == '1' ? $t('discountCode.deduction') : $t('discountCode.discount') }}:
|
|
|
+ </span>
|
|
|
+ {{ item.discount }}
|
|
|
+ </div>
|
|
|
+ <div class="itemRow">
|
|
|
+ <span class="itemTitle">
|
|
|
+ {{ $t('discountCode.creationTime') }}:
|
|
|
+ </span>
|
|
|
+ {{ showDateTime(item.createDate) }}
|
|
|
+ </div>
|
|
|
+ <div class="itemRow" v-if="user.type < 2">
|
|
|
+ <span class="itemTitle">
|
|
|
+ {{ $t('discountCode.affiliatedMerchants') }}:
|
|
|
+ </span>
|
|
|
+ {{ item.userName }}
|
|
|
+ </div>
|
|
|
+ <div class="itemRow" v-if="item.isUse !== '0'">
|
|
|
+ <span class="itemTitle">
|
|
|
+ {{ $t('discountCode.usageTime') }}:
|
|
|
+ </span>
|
|
|
+ {{ showDateTime(item.useDate) }}
|
|
|
+ </div>
|
|
|
+ <div class="itemRow">
|
|
|
+ <span class="itemTitle">
|
|
|
+ {{ $t('discountCode.termOfValidity') }}:
|
|
|
+ </span>{{ showDate(item.lastUseDate) }}
|
|
|
+ <span v-if="item.isUse === '0' && isExpired(item.lastUseDate)">
|
|
|
+ {{ $t('discountCode.expired') }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div class="itemRow" v-if="item.isUse !== '0'">
|
|
|
+ <span class="itemTitle">
|
|
|
+ {{ $t('discountCode.usingTheMachine') }}:
|
|
|
+ </span>
|
|
|
+ {{ item.useBy }}
|
|
|
</div>
|
|
|
- <div class="itemRow"><span class="itemTitle">{{ $t('discountCode.creationTime') }}: </span>{{
|
|
|
- showDateTime(item.createDate) }}</div>
|
|
|
- <div class="itemRow" v-if="item.isUse !== '0'"><span class="itemTitle">{{ $t('discountCode.usageTime') }}: </span>{{
|
|
|
- showDateTime(item.useDate) }}</div>
|
|
|
- <div class="itemRow"><span class="itemTitle">{{ $t('discountCode.termOfValidity') }}: </span>{{
|
|
|
- showDate(item.lastUseDate) }} <span v-if="item.isUse === '0' && isExpired(item.lastUseDate)">{{ $t('discountCode.expired') }}</span></div>
|
|
|
- <div class="itemRow" v-if="item.isUse !== '0'"><span class="itemTitle">{{ $t('discountCode.usingTheMachine') }}: </span>{{
|
|
|
- item.useBy }}</div>
|
|
|
</div>
|
|
|
- <div class="tipBox" v-if="item.isUse === '0'">{{ $t('discountCode.notUsed') }}</div>
|
|
|
- <div class="tipBox isUseTip" v-if="item.isUse === '1'">{{ $t('discountCode.used') }}</div>
|
|
|
+ <div class="tipBox" v-if="item.isUse === '0' && isDelete == false">
|
|
|
+ {{ $t('discountCode.notUsed') }}
|
|
|
+ </div>
|
|
|
+ <div class="tipBox isUseTip" v-if="item.isUse === '1' && isDelete == false">
|
|
|
+ {{ $t('discountCode.used') }}
|
|
|
+ </div>
|
|
|
+ <div v-if="isDelete" class="checkedBox">
|
|
|
+ <van-checkbox v-model="item.checked"></van-checkbox>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</van-list>
|
|
@@ -59,19 +115,22 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { onMounted, reactive, toRefs, ref } from "vue";
|
|
|
+import { onMounted, reactive, toRefs, ref, computed } from "vue";
|
|
|
import sHeader from "@/components/SimpleHeader";
|
|
|
-import { getdiscountCodeList, discountCodeExport } from "@/service/discountCode";
|
|
|
-import { showFailToast } from "vant";
|
|
|
+import { getdiscountCodeList, discountCodeExport, deleteCode } from "@/service/discountCode";
|
|
|
+import { showFailToast, showToast, showConfirmDialog } from "vant";
|
|
|
import { getLoginUser, $M_ExportFile, styleUrl } from "@/common/js/utils";
|
|
|
import codeSearch from './codeSearch.vue';
|
|
|
import dateUtil from "@/utils/dateUtil";
|
|
|
import { useRouter } from "vue-router";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
|
|
|
export default {
|
|
|
setup() {
|
|
|
+ const { t } = useI18n();
|
|
|
const router = useRouter();
|
|
|
const searchRef = ref(null);
|
|
|
+ const user = getLoginUser();
|
|
|
const loading = ref(false); // 加载状态
|
|
|
const error = ref(false); // 错误状态
|
|
|
const finished = ref(false); // 结束翻页状态
|
|
@@ -112,8 +171,15 @@ export default {
|
|
|
const getList = async () => {
|
|
|
const { data } = await getdiscountCodeList(Object.assign({}, searchParams));
|
|
|
if (data.code === "00000") {
|
|
|
+ // 加入删除选中状态
|
|
|
+ if (data.data.records.length > 0) {
|
|
|
+ data.data.records.forEach((item) => {
|
|
|
+ item.checked = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
// 列表值叠加
|
|
|
discountCodeList.value = discountCodeList.value.concat(data.data.records);
|
|
|
+ // console.log(discountCodeList.value);
|
|
|
discountCodeTotal.value = data.data.total;
|
|
|
if (discountCodeList.value.length === data.data.total) { finished.value = true; }
|
|
|
loading.value = false;
|
|
@@ -142,6 +208,75 @@ export default {
|
|
|
return currentDate > lastUseDateTime;
|
|
|
});
|
|
|
|
|
|
+ // 是否删除状态
|
|
|
+ const isDelete = ref(false); // 选中
|
|
|
+ const selectTotals = computed(() => {
|
|
|
+ let nums = 0;
|
|
|
+ if (discountCodeList.value.length > 0) {
|
|
|
+ discountCodeList.value.forEach((item) => {
|
|
|
+ if (item.checked) {
|
|
|
+ nums++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return nums;
|
|
|
+ });
|
|
|
+ const cancelClk = () => {
|
|
|
+ // 把选中状态去掉
|
|
|
+ if (discountCodeList.value.length > 0) {
|
|
|
+ discountCodeList.value.forEach((item) => {
|
|
|
+ if (item.checked) {
|
|
|
+ item.checked = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ isDelete.value = false;
|
|
|
+ };
|
|
|
+ // 点击全选
|
|
|
+ const allClk = () => {
|
|
|
+ if (discountCodeList.value.length > 0) {
|
|
|
+ discountCodeList.value.forEach((item) => {
|
|
|
+ item.checked = true;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // 点击确认删除
|
|
|
+ const noticeClk = () => {
|
|
|
+ if (selectTotals.value < 1) {
|
|
|
+ showToast(t("advertManage.delTips"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ showConfirmDialog({
|
|
|
+ title: t('advertManage.delPopTitle'),
|
|
|
+ message: t('advertManage.delPopContent'),
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ const ids = [];
|
|
|
+ discountCodeList.value.forEach((item) => {
|
|
|
+ if (item.checked) {
|
|
|
+ ids.push(item.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ deleteCode(ids).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.data.code === '00000') {
|
|
|
+ isDelete.value = false;
|
|
|
+ showToast(t('discountCode.deletionSucceeded'));
|
|
|
+ setTimeout(() => {
|
|
|
+ discountCodeList.value = [];
|
|
|
+ getList();
|
|
|
+ }, 1500);
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ isDelete.value = false;
|
|
|
+ showToast('ERROR');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ // showToast('ERROR');
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
return {
|
|
|
searchRef,
|
|
|
loading,
|
|
@@ -160,6 +295,12 @@ export default {
|
|
|
exportClick,
|
|
|
payCode,
|
|
|
isExpired,
|
|
|
+ isDelete,
|
|
|
+ allClk,
|
|
|
+ noticeClk,
|
|
|
+ selectTotals,
|
|
|
+ cancelClk,
|
|
|
+ user,
|
|
|
};
|
|
|
},
|
|
|
components: { sHeader, codeSearch },
|