feat(cities): cities are a tree again, as legacy's; old dashboard permissions merged (PERS-02, PERM-01)

Cities (owner: as legacy)
- City.parentId (self relation) replaces the flat `province` label; the
  migration turns each label into a parent row («استان …») first, so nothing
  is lost.
- Admin pickers are legacy's tree (CityTreeSelect): the top level, the
  country, is a heading. The city form and grid get «والد».
- Restored legacy _getP: a city without its own percent takes its
  ancestor's. Restored the omde-customer form's city → percent autofill.
- Import copies legacy parents; delete refuses a city with children; a
  parent loop is refused.

Permissions (owner approved the deletion)
- dashboard / dashboard.omde / dashboard.tak rows become dashboard.view,
  then are deleted.
- Import maps them the same way: legacy types 102, 104, 105, 108 and 135
  had lost the dashboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
s.esmaeili
2026-10-08 16:31:12 +03:30
co-authored by Claude Opus 5.5
parent fbe7b98ada
commit fbe4f38e06
17 changed files with 467 additions and 126 deletions
+35 -7
View File
@@ -22,8 +22,14 @@
<a-form-item label="نام شهر" :validate-status="err.title ? 'error' : ''" :help="err.title">
<a-input v-model:value="form.title" />
</a-form-item>
<a-form-item label="استان">
<a-input v-model:value="form.province" />
<a-form-item label="والد" help="خالی = سرشاخه، مثل کشور">
<CityTreeSelect v-model:value="form.parent" :cities="cities" parent-picker placeholder="والد را انتخاب کنید" />
</a-form-item>
<a-form-item label="درصد مشتری عمده">
<a-input-number v-model:value="form.percent" class="w-full" :min="0" :max="100" :step="0.1" />
</a-form-item>
<a-form-item label="درصد کارشناس فروش">
<a-input-number v-model:value="form.percent_aux" class="w-full" :min="0" :max="100" :step="0.1" />
</a-form-item>
</div>
</BaseFormModal>
@@ -36,8 +42,14 @@
<a-form-item label="نام شهر" :validate-status="err.title ? 'error' : ''" :help="err.title">
<a-input v-model:value="form.title" />
</a-form-item>
<a-form-item label="استان">
<a-input v-model:value="form.province" />
<a-form-item label="والد" help="خالی = سرشاخه، مثل کشور">
<CityTreeSelect v-model:value="form.parent" :cities="cities" parent-picker placeholder="والد را انتخاب کنید" />
</a-form-item>
<a-form-item label="درصد مشتری عمده">
<a-input-number v-model:value="form.percent" class="w-full" :min="0" :max="100" :step="0.1" />
</a-form-item>
<a-form-item label="درصد کارشناس فروش">
<a-input-number v-model:value="form.percent_aux" class="w-full" :min="0" :max="100" :step="0.1" />
</a-form-item>
</div>
<a-button type="primary" @click="handleSubmit">ثبت اطلاعات</a-button>
@@ -47,11 +59,12 @@
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import { onMounted, reactive, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
import BaseFormModal from '../../components/common/BaseFormModal.vue';
import api from '../../api/client';
import CityTreeSelect from '../../components/common/CityTreeSelect.vue';
const props = defineProps<{
/** Present -> rendered as a modal by the parent list page. */
@@ -71,7 +84,20 @@ const route = useRoute();
const router = useRouter();
const loading = ref(false);
const form = reactive<Record<string, any>>({ title: '', province: '' });
const form = reactive<Record<string, any>>({ title: '', parent: undefined, percent: null, percent_aux: null });
const cities = ref<{ id: string; title: string; parent?: string | null }[]>([]);
async function loadCities() {
try {
const { data } = await api.post('cities/list');
cities.value = data.rows ?? [];
} catch (e) {
console.log(e);
}
}
// Fresh each time the modal opens, so a city added a moment ago can be a parent.
if (asModal) watch(() => props.open, (o) => o && loadCities(), { immediate: true });
else onMounted(loadCities);
const err = reactive<Record<string, string>>({});
async function handleSubmit() {
@@ -82,9 +108,11 @@ async function handleSubmit() {
}
try {
loading.value = true;
await api.post('cities', form);
await api.post('cities', { ...form, parent: form.parent ?? null });
message.info('اطلاعات با موفقیت به ثبت رسید.');
if (asModal) {
// Keep the parent: cities are usually added several under the same one.
Object.assign(form, { title: '', percent: null, percent_aux: null });
emit('success');
emit('update:open', false);
} else {