|
@@ -39,7 +39,7 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
<div class="w-full flex p-3 shadow-[0_-3px_5px_0px_rgba(0,0,0,0.2)]">
|
|
|
- <El-button class="w-full">重置</El-Button>
|
|
|
+ <El-button class="w-full" @click="resetForm()">重置</El-Button>
|
|
|
<El-button type="primary" class="w-full" @click="getBusinessTableList()">搜索</El-Button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -102,16 +102,18 @@
|
|
|
<div class="flex justify-between items-center border-b pb-3 dialog-header">
|
|
|
<h4 :id="titleId">{{ allText.newBusinessisibleText }}</h4>
|
|
|
<div>
|
|
|
- <el-button type="primary">保存并新建</el-button>
|
|
|
- <el-button type="primary" @click="editBusiness()">保存</el-button>
|
|
|
+ <el-button type="primary" :loading="allLoading.newBusinessSaveLading"
|
|
|
+ :disabled="allLoading.businessSaveLading" @click="editBusiness(true)">保存并新建</el-button>
|
|
|
+ <el-button type="primary" @click="editBusiness(false)" :loading="allLoading.businessSaveLading"
|
|
|
+ :disabled="allLoading.newBusinessSaveLading">保存</el-button>
|
|
|
<el-button @click="closeVisible('newBusinessisible')">取消</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <div class="h-[60vh] overflow-y-auto scroll-bar">
|
|
|
+ <div class="h-[60vh] overflow-y-auto scroll-bar pt-3">
|
|
|
<GenerateForm ref="generateForm" :data="generateFormData" />
|
|
|
<div>相关产品</div>
|
|
|
- <RelatedProducts :productTableList="productTableList" />
|
|
|
+ <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList" />
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -121,7 +123,7 @@
|
|
|
import { ref, reactive, onMounted, inject } from "vue";
|
|
|
import type { FormInstance, FormRules } from 'element-plus'
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
-import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST } from './api'
|
|
|
+import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET } from './api'
|
|
|
import { GETTABLELIST } from '@/pages/product/api'
|
|
|
import { post, get } from "@/utils/request";
|
|
|
import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate } from '@/utils/tools'
|
|
@@ -133,17 +135,18 @@ const router = useRouter()
|
|
|
const globalPopup = inject<GlobalPopup>('globalPopup')
|
|
|
const businessTotalTable = ref(0)
|
|
|
const generateForm = ref<typeof GenerateForm>() // 自定义表单dom
|
|
|
+const relatedProductsRef = ref<typeof RelatedProducts>()
|
|
|
const generateFormData = ref({
|
|
|
config: {},
|
|
|
list: []
|
|
|
}) // 自定义表单数据
|
|
|
-const businessTable = ref([
|
|
|
- { name: '商机040101', phone: '张山' }
|
|
|
-])
|
|
|
-const allLoading = reactive<AllLoadingInterface>({
|
|
|
- businessTableLading: false
|
|
|
+const businessTable = ref([])
|
|
|
+const allLoading = reactive({
|
|
|
+ businessTableLading: false,
|
|
|
+ businessSaveLading: false,
|
|
|
+ newBusinessSaveLading: false,
|
|
|
})
|
|
|
-const allVisible = reactive<AllVisibleInterface>({
|
|
|
+const allVisible = reactive({
|
|
|
newBusinessisible: false,
|
|
|
recycleVisible: false,
|
|
|
})
|
|
@@ -170,20 +173,33 @@ const fixedData = reactive({
|
|
|
const productTableList = ref([])
|
|
|
|
|
|
|
|
|
-function editBusiness() {
|
|
|
+function editBusiness(visibles: boolean) {
|
|
|
generateForm.value?.getData().then((res: any) => {
|
|
|
- console.log('正确')
|
|
|
- console.log(res)
|
|
|
+ let productTableListData = relatedProductsRef?.value?.returnData()
|
|
|
+ let newForm = {
|
|
|
+ ...res,
|
|
|
+ expectedTransactionDate: res.expectedTransactionDate ? formatDate(new Date(res.expectedTransactionDate)) : '',
|
|
|
+ businessItemProductList: productTableListData ? JSON.stringify(productTableListData) : []
|
|
|
+ }
|
|
|
+ allLoading.businessSaveLading = true
|
|
|
+ post(UPDATEINSET, { ...newForm }).then((_res) => {
|
|
|
+ allVisible.newBusinessisible = visibles
|
|
|
+ globalPopup?.showSuccess('保存成功')
|
|
|
+ getBusinessTableList()
|
|
|
+ }).finally(() => {
|
|
|
+ allLoading.businessSaveLading = false
|
|
|
+ })
|
|
|
}).catch((_err: any) => {
|
|
|
+ console.log(_err)
|
|
|
globalPopup?.showError('请填写完整')
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function showVisible(type: keyof AllVisibleInterface) { // 显示弹窗
|
|
|
+function showVisible(type: keyof typeof allVisible) { // 显示弹窗
|
|
|
allVisible[type] = true
|
|
|
}
|
|
|
|
|
|
-function closeVisible(type: keyof AllVisibleInterface) {
|
|
|
+function closeVisible(type: keyof typeof allVisible) {
|
|
|
allVisible[type] = false
|
|
|
}
|
|
|
|
|
@@ -193,14 +209,25 @@ function handleClose(done: () => void) {
|
|
|
|
|
|
function getBusinessTableList() {
|
|
|
const formValue = getFromValue(businessOpportunityForm)
|
|
|
- post(GETBUSINESSLIST, {...formValue }).then((res) => {
|
|
|
- console.log(res, '<==== 返回的数据')
|
|
|
+ post(GETBUSINESSLIST, { ...formValue }).then((res) => {
|
|
|
const { data, total } = res.data
|
|
|
businessTable.value = data
|
|
|
businessTotalTable.value = total
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+function resetForm() {
|
|
|
+ let reset = {
|
|
|
+ startTime: getFirstDayOfMonth(new Date()),
|
|
|
+ endTime: formatDate(new Date()),
|
|
|
+ pageIndex: 1,
|
|
|
+ pageFrom: 10
|
|
|
+ }
|
|
|
+ let newBusinessOpportunityForm = resetFromValue(businessOpportunityForm, { ...reset })
|
|
|
+ Object.assign(businessOpportunityForm, newBusinessOpportunityForm)
|
|
|
+ getBusinessTableList()
|
|
|
+}
|
|
|
+
|
|
|
async function getSystemField() {
|
|
|
const systemField = getAllListByCode(['商机阶段'])
|
|
|
for (let i in systemField) {
|
|
@@ -239,6 +266,7 @@ function getProductTableList() {
|
|
|
productTableList.value = record.map((item: any) => {
|
|
|
const { id, productName, productCode, unit, unitName, typeName, type, price, inventory } = item
|
|
|
return {
|
|
|
+ id,
|
|
|
productId: id,
|
|
|
productName,
|
|
|
productCode,
|