| | |
| | | data: query |
| | | }) |
| | | } |
| | | // å·¡æ£ä»»å¡è¡¨æ°å¢ä¿®æ¹ |
| | | // å·¡æ£ä»»å¡è¡¨å é¤ |
| | | export function delInspectionTask(query) { |
| | | return request({ |
| | | url: '/inspectionTask/delInspectionTask', |
| | |
| | | // è·åè·¯ç± |
| | | export const testUserList = () => { |
| | | return request({ |
| | | url: '/test/user/list', |
| | | url: '/system/user/listAll', |
| | | method: 'get' |
| | | }) |
| | | } |
| | |
| | | :row-key="rowKey" |
| | | style="width: 100%;" |
| | | > |
| | | <el-table-column v-if="showSelection" type="selection" width="55" align="center" /> |
| | | <el-table-column v-if="showIndex" label="åºå·" width="60" align="center" fixed="left"> |
| | | <el-table-column v-if="showSelection" type="selection" width="55" align="center" :show-overflow-tooltip="false" /> |
| | | <el-table-column v-if="showIndex" label="åºå·" width="60" align="center" fixed="left" :show-overflow-tooltip="false"> |
| | | <template #default="scope"> |
| | | {{ getRowIndex(scope.$index) }} |
| | | </template> |
| | |
| | | <el-button v-if="operations.includes('edit')" link type="primary" size="small" |
| | | @click="handleEdit(scope.row)">ç¼è¾</el-button> |
| | | <el-button v-if="operations.includes('viewRow')" link type="primary" size="small" |
| | | @click="handleView(scope.row)">æ¥çéä»¶</el-button> |
| | | @click="handleView(scope.row)">æ¥ç</el-button> |
| | | <el-button v-if="operations.includes('viewFile')" link type="primary" size="small" |
| | | @click="handleViewFile(scope.row)">æ¥çéä»¶</el-button> |
| | | </slot> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | }; |
| | | |
| | | // å¤çéæ©ååãç¼è¾ãå é¤åå¯¼åºæä½ |
| | | const emit = defineEmits(['selection-change', 'edit', 'delete', 'export', 'viewRow']) |
| | | const emit = defineEmits(['selection-change', 'edit', 'delete', 'export', 'viewRow', 'viewFile']) |
| | | const handleSelectionChange = (selection) => { |
| | | emit('selection-change', selection) |
| | | } |
| | |
| | | const handleView = (row) => { |
| | | emit('viewRow', row) |
| | | } |
| | | const handleViewFile = (row) => { |
| | | emit('viewFile', row) |
| | | } |
| | | const handleDelete = (row) => { |
| | | ElMessageBox.confirm( |
| | | props.deleteConfirmText, |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /** |
| | | * éç¨å é¤åè½ç»åå¼å½æ° |
| | | * æä¾ç»ä¸çå é¤ç¡®è®¤ãAPIè°ç¨ãæ°æ®æ´æ°é»è¾ |
| | | */ |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | |
| | | /** |
| | | * å建å é¤åè½ |
| | | * @param {Object} options é
ç½®é项 |
| | | * @param {Function|Function} options.deleteApi å é¤API彿°æè¿åAPI彿°ç彿° |
| | | * @param {Function|Function} options.getList éæ°è·ååè¡¨æ°æ®ç彿°æè¿å彿°ç彿° |
| | | * @param {Ref} options.selectedRows éä¸è¡çååºå¼å¼ç¨ |
| | | * @param {Ref} options.tableData è¡¨æ ¼æ°æ®çååºå¼å¼ç¨ |
| | | * @param {Ref} options.total æ»æ°çååºå¼å¼ç¨ |
| | | * @param {String} options.confirmText 确认å é¤çæç¤ºææ¬ |
| | | * @param {String} options.successText å 餿åçæç¤ºææ¬ |
| | | * @param {Boolean} options.useLocalUpdate æ¯å¦ä½¿ç¨æ¬å°æ´æ°ï¼ä¸éæ°è¯·æ±æ¥å£ï¼ |
| | | * @returns {Object} è¿åå é¤ç¸å
³çæ¹æ³ |
| | | */ |
| | | export function useDelete(options = {}) { |
| | | const { |
| | | deleteApi, |
| | | getList, |
| | | selectedRows, |
| | | tableData, |
| | | total, |
| | | confirmText = "ç¡®å®å é¤éä¸çæ°æ®åï¼", |
| | | successText = "å 餿å", |
| | | useLocalUpdate = false |
| | | } = options; |
| | | |
| | | /** |
| | | * è·åå®é
çå é¤API彿° |
| | | * æ¯æç´æ¥ä¼ å
¥å½æ°æè¿å彿°ç彿° |
| | | */ |
| | | const getDeleteApi = () => { |
| | | if (typeof deleteApi === 'function') { |
| | | // å°è¯è°ç¨çæ¯å¦è¿å彿° |
| | | try { |
| | | const result = deleteApi(); |
| | | return typeof result === 'function' ? result : deleteApi; |
| | | } catch (error) { |
| | | // 妿è°ç¨åºéï¼è¯´æè¿æ¬èº«å°±æ¯API彿° |
| | | return deleteApi; |
| | | } |
| | | } |
| | | return deleteApi; |
| | | }; |
| | | |
| | | /** |
| | | * è·åå®é
çè·ååè¡¨å½æ° |
| | | * æ¯æç´æ¥ä¼ å
¥å½æ°æè¿å彿°ç彿° |
| | | */ |
| | | const getListFunction = () => { |
| | | if (typeof getList === 'function') { |
| | | try { |
| | | const result = getList(); |
| | | return typeof result === 'function' ? result : getList; |
| | | } catch (error) { |
| | | // 妿è°ç¨åºéï¼è¯´æè¿æ¬èº«å°±æ¯åè¡¨å½æ° |
| | | return getList; |
| | | } |
| | | } |
| | | return getList; |
| | | }; |
| | | |
| | | /** |
| | | * æ¹éå 餿¹æ³ |
| | | * @param {Array} customIds èªå®ä¹è¦å é¤çIDæ°ç»ï¼å¦æä¸ä¼ å使ç¨selectedRows |
| | | */ |
| | | const handleDelete = async (customIds = null) => { |
| | | // ç¡®å®è¦å é¤çè¡ |
| | | const rowsToDelete = customIds ? |
| | | tableData.value.filter(item => customIds.includes(item.id)) : |
| | | selectedRows.value; |
| | | |
| | | // æ£æ¥æ¯å¦æé䏿°æ® |
| | | if (rowsToDelete.length === 0) { |
| | | ElMessage.warning("è¯·éæ©è¦å é¤çæ°æ®"); |
| | | return false; |
| | | } |
| | | |
| | | try { |
| | | // 确认å é¤ |
| | | await ElMessageBox.confirm(confirmText, "æç¤º", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }); |
| | | |
| | | // æåID |
| | | const ids = rowsToDelete.map(item => item.id); |
| | | |
| | | // è·åå½åçå é¤API彿° |
| | | const currentDeleteApi = getDeleteApi(); |
| | | if (!currentDeleteApi) { |
| | | ElMessage.error("å é¤APIæªé
ç½®"); |
| | | return false; |
| | | } |
| | | |
| | | // è°ç¨å é¤API |
| | | const res = await currentDeleteApi(ids); |
| | | |
| | | if (res.code === 200) { |
| | | // æ ¹æ®é
ç½®éæ©æ´æ°æ¹å¼ |
| | | if (useLocalUpdate) { |
| | | // æ¬å°æ´æ°ï¼ä»è¡¨æ ¼æ°æ®ä¸ç§»é¤å·²å é¤ç项 |
| | | tableData.value = tableData.value.filter(item => !ids.includes(item.id)); |
| | | if (total && total.value !== undefined) { |
| | | total.value = tableData.value.length; |
| | | } |
| | | } else { |
| | | // éæ°è·åæ°æ® |
| | | const currentGetList = getListFunction(); |
| | | if (currentGetList) { |
| | | await currentGetList(); |
| | | } |
| | | } |
| | | |
| | | // æ¸
空éä¸ç¶æ |
| | | if (selectedRows && selectedRows.value) { |
| | | selectedRows.value = []; |
| | | } |
| | | |
| | | ElMessage.success(successText); |
| | | return true; |
| | | } else { |
| | | ElMessage.error("å é¤å¤±è´¥ï¼" + (res.msg || "æªç¥é误")); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | if (error !== "cancel") { |
| | | console.error("å 餿ä½å¤±è´¥:", error); |
| | | ElMessage.error("å é¤å¤±è´¥ï¼" + (error.message || "请ç¨åéè¯")); |
| | | } else { |
| | | ElMessage.info("已忶å é¤"); |
| | | } |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * å é¤åä¸ªé¡¹ç® |
| | | * @param {Object} row è¦å é¤çè¡æ°æ® |
| | | */ |
| | | const handleDeleteSingle = async (row) => { |
| | | return await handleDelete([row.id]); |
| | | }; |
| | | |
| | | /** |
| | | * å é¤å¤ä¸ªé¡¹ç®ï¼æ¹éå é¤ï¼ |
| | | */ |
| | | const handleDeleteBatch = async () => { |
| | | return await handleDelete(); |
| | | }; |
| | | |
| | | return { |
| | | handleDelete, |
| | | handleDeleteSingle, |
| | | handleDeleteBatch |
| | | }; |
| | | } |
| | |
| | | import { reactive } from "vue"; |
| | | /** |
| | | * éç¨è¡¨åæ°æ®ç®¡çç»åå¼å½æ° |
| | | * æä¾è¡¨åæ°æ®çå¢å æ¹æ¥ãéªè¯ãéç½®çåè½ |
| | | */ |
| | | import { ref, reactive, computed, nextTick } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import { clone } from "lodash"; |
| | | |
| | | /** |
| | | * åå»ºè¡¨åæ°æ®ç®¡çåè½ |
| | | * @param {Object} options é
ç½®é项 |
| | | * @param {Object} options.defaultForm é»è®¤è¡¨åç»æ |
| | | * @param {Function} options.addApi æ°å¢API彿° |
| | | * @param {Function} options.updateApi æ´æ°API彿° |
| | | * @param {Function} options.getDetailApi è·å详æ
API彿° |
| | | * @param {Object} options.rules 表åéªè¯è§å |
| | | * @param {Function} options.beforeSubmit æäº¤åçæ°æ®å¤ç彿° |
| | | * @param {Function} options.afterSubmit æäº¤åçåè°å½æ° |
| | | * @param {Boolean} options.autoReset æäº¤æå忝å¦èªå¨é置表å |
| | | * @returns {Object} è¿å表å管çç¸å
³çæ¹æ³åç¶æ |
| | | */ |
| | | export function useFormData(options = {}) { |
| | | const { |
| | | defaultForm = {}, |
| | | addApi, |
| | | updateApi, |
| | | getDetailApi, |
| | | rules = {}, |
| | | beforeSubmit, |
| | | afterSubmit, |
| | | autoReset = true |
| | | } = options; |
| | | |
| | | export default function useFormData(initData) { |
| | | // 表åç¶æ |
| | | const form = ref({ ...defaultForm }); |
| | | const originalForm = ref({ ...defaultForm }); |
| | | const loading = ref(false); |
| | | const dialogVisible = ref(false); |
| | | const mode = ref('add'); // 'add', 'edit', 'view' |
| | | const title = ref(''); |
| | | const formRef = ref(null); |
| | | |
| | | // 计ç®å±æ§ |
| | | const isAdd = computed(() => mode.value === 'add'); |
| | | const isEdit = computed(() => mode.value === 'edit'); |
| | | const isView = computed(() => mode.value === 'view'); |
| | | const isReadonly = computed(() => mode.value === 'view'); |
| | | const submitButtonText = computed(() => { |
| | | return isAdd.value ? 'æ°å¢' : 'ä¿å'; |
| | | }); |
| | | |
| | | /** |
| | | * æå¼è¡¨åå¯¹è¯æ¡ |
| | | * @param {String} formMode è¡¨åæ¨¡å¼ï¼'add', 'edit', 'view' |
| | | * @param {Object} data ç¼è¾/æ¥çæ¶çæ°æ® |
| | | * @param {String} customTitle èªå®ä¹æ é¢ |
| | | */ |
| | | const openForm = async (formMode = 'add', data = null, customTitle = '') => { |
| | | mode.value = formMode; |
| | | |
| | | // 设置æ é¢ |
| | | if (customTitle) { |
| | | title.value = customTitle; |
| | | } else { |
| | | const titleMap = { |
| | | add: 'æ°å¢', |
| | | edit: 'ç¼è¾', |
| | | view: 'æ¥ç' |
| | | }; |
| | | title.value = titleMap[formMode] || '表å'; |
| | | } |
| | | |
| | | // æ ¹æ®æ¨¡å¼å¤çæ°æ® |
| | | if (formMode === 'add') { |
| | | resetForm(); |
| | | } else if (data) { |
| | | // ç¼è¾/æ¥ç模å¼ï¼å¦ææè¯¦æ
APIåè·åææ°æ°æ® |
| | | if (getDetailApi && data.id) { |
| | | loading.value = true; |
| | | try { |
| | | const res = await getDetailApi(data.id); |
| | | if (res.code === 200) { |
| | | setFormData(res.data); |
| | | } else { |
| | | ElMessage.error('è·å详æ
失败'); |
| | | setFormData(data); |
| | | } |
| | | } catch (error) { |
| | | console.error('è·å详æ
失败:', error); |
| | | setFormData(data); |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | } else { |
| | | setFormData(data); |
| | | } |
| | | } |
| | | |
| | | dialogVisible.value = true; |
| | | }; |
| | | |
| | | /** |
| | | * è®¾ç½®è¡¨åæ°æ® |
| | | * @param {Object} data è¡¨åæ°æ® |
| | | */ |
| | | const setFormData = (data) => { |
| | | form.value = { ...defaultForm, ...data }; |
| | | originalForm.value = { ...form.value }; |
| | | }; |
| | | |
| | | /** |
| | | * é置表å |
| | | */ |
| | | const resetForm = () => { |
| | | form.value = { ...defaultForm }; |
| | | originalForm.value = { ...defaultForm }; |
| | | if (formRef.value) { |
| | | formRef.value.resetFields(); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * æ¢å¤è¡¨åå°åå§ç¶æ |
| | | */ |
| | | const restoreForm = () => { |
| | | form.value = { ...originalForm.value }; |
| | | if (formRef.value) { |
| | | formRef.value.clearValidate(); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 表åéªè¯ |
| | | * @returns {Promise<Boolean>} éªè¯ç»æ |
| | | */ |
| | | const validateForm = async () => { |
| | | if (!formRef.value) return true; |
| | | |
| | | try { |
| | | await formRef.value.validate(); |
| | | return true; |
| | | } catch (error) { |
| | | console.log('表åéªè¯å¤±è´¥:', error); |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * æäº¤è¡¨å |
| | | * @param {Object} customData èªå®ä¹æäº¤æ°æ® |
| | | * @returns {Promise<Boolean>} æäº¤ç»æ |
| | | */ |
| | | const submitForm = async (customData = null) => { |
| | | // éªè¯è¡¨å |
| | | const isValid = await validateForm(); |
| | | if (!isValid) { |
| | | ElMessage.warning('è¯·æ£æ¥è¡¨åæ°æ®'); |
| | | return false; |
| | | } |
| | | |
| | | // åå¤æäº¤æ°æ® |
| | | let submitData = customData || { ...form.value }; |
| | | |
| | | // æ§è¡æäº¤åå¤ç |
| | | if (beforeSubmit && typeof beforeSubmit === 'function') { |
| | | try { |
| | | submitData = await beforeSubmit(submitData, mode.value); |
| | | } catch (error) { |
| | | console.error('æäº¤åå¤ç失败:', error); |
| | | ElMessage.error('æ°æ®å¤ç失败'); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | loading.value = true; |
| | | |
| | | try { |
| | | let res; |
| | | |
| | | if (isAdd.value && addApi) { |
| | | res = await addApi(submitData); |
| | | } else if (isEdit.value && updateApi) { |
| | | res = await updateApi(submitData); |
| | | } else { |
| | | ElMessage.error('æªé
ç½®ç¸åºçAPIæ¥å£'); |
| | | return false; |
| | | } |
| | | |
| | | if (res.code === 200) { |
| | | const action = isAdd.value ? 'æ°å¢' : 'æ´æ°'; |
| | | ElMessage.success(`${action}æå`); |
| | | |
| | | // æ§è¡æäº¤ååè° |
| | | if (afterSubmit && typeof afterSubmit === 'function') { |
| | | await afterSubmit(res.data, mode.value, submitData); |
| | | } |
| | | |
| | | // èªå¨é置表å |
| | | if (autoReset) { |
| | | closeForm(); |
| | | } |
| | | |
| | | return true; |
| | | } else { |
| | | ElMessage.error(res.msg || 'æä½å¤±è´¥'); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | console.error('æäº¤å¤±è´¥:', error); |
| | | ElMessage.error('æä½å¤±è´¥ï¼è¯·ç¨åéè¯'); |
| | | return false; |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * å
³é表åå¯¹è¯æ¡ |
| | | */ |
| | | const closeForm = () => { |
| | | dialogVisible.value = false; |
| | | resetForm(); |
| | | }; |
| | | |
| | | /** |
| | | * æ£æ¥è¡¨åæ¯å¦æåæ´ |
| | | * @returns {Boolean} æ¯å¦æåæ´ |
| | | */ |
| | | const hasChanges = computed(() => { |
| | | return JSON.stringify(form.value) !== JSON.stringify(originalForm.value); |
| | | }); |
| | | |
| | | /** |
| | | * 带确认çå
³é表å |
| | | */ |
| | | const closeFormWithConfirm = async () => { |
| | | if (hasChanges.value && !isView.value) { |
| | | try { |
| | | await ElMessageBox.confirm('è¡¨åæ°æ®å·²ä¿®æ¹ï¼ç¡®å®è¦ç¦»å¼åï¼', 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning', |
| | | }); |
| | | closeForm(); |
| | | } catch { |
| | | // ç¨æ·åæ¶ |
| | | } |
| | | } else { |
| | | closeForm(); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 设置表ååæ®µå¼ |
| | | * @param {String} field åæ®µå |
| | | * @param {Any} value åæ®µå¼ |
| | | */ |
| | | const setFieldValue = (field, value) => { |
| | | form.value[field] = value; |
| | | }; |
| | | |
| | | /** |
| | | * è·å表ååæ®µå¼ |
| | | * @param {String} field åæ®µå |
| | | * @returns {Any} åæ®µå¼ |
| | | */ |
| | | const getFieldValue = (field) => { |
| | | return form.value[field]; |
| | | }; |
| | | |
| | | /** |
| | | * æ¹é设置表ååæ®µå¼ |
| | | * @param {Object} values åæ®µå¼å¯¹è±¡ |
| | | */ |
| | | const setFieldValues = (values) => { |
| | | Object.keys(values).forEach(key => { |
| | | if (form.value.hasOwnProperty(key)) { |
| | | form.value[key] = values[key]; |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * æ¸
é¤å段éªè¯ |
| | | * @param {String|Array} fields åæ®µåæåæ®µåæ°ç» |
| | | */ |
| | | const clearValidate = (fields = null) => { |
| | | if (formRef.value) { |
| | | formRef.value.clearValidate(fields); |
| | | } |
| | | }; |
| | | |
| | | return { |
| | | // ç¶æ |
| | | form, |
| | | loading, |
| | | dialogVisible, |
| | | mode, |
| | | title, |
| | | formRef, |
| | | |
| | | // 计ç®å±æ§ |
| | | isAdd, |
| | | isEdit, |
| | | isView, |
| | | isReadonly, |
| | | submitButtonText, |
| | | hasChanges, |
| | | |
| | | // æ¹æ³ |
| | | openForm, |
| | | setFormData, |
| | | resetForm, |
| | | restoreForm, |
| | | validateForm, |
| | | submitForm, |
| | | closeForm, |
| | | closeFormWithConfirm, |
| | | setFieldValue, |
| | | getFieldValue, |
| | | setFieldValues, |
| | | clearValidate |
| | | }; |
| | | } |
| | | |
| | | // ååå
¼å®¹çé»è®¤å¯¼åº |
| | | export default function useFormDataSimple(initData) { |
| | | const form = reactive(clone(initData, true)); |
| | | |
| | | function resetForm() { |
| | |
| | | const tableSwitch = ref(false); |
| | | // å¤çèç¹ç¹å» |
| | | const handleNodeClick = (data) => { |
| | | console.log("ç¹å»èç¹", data); |
| | | rowClickData.value = data; // åå¨å½åç¹å»çèç¹æ°æ® |
| | | tableSwitch.value = true; |
| | | // 忢èç¹æ¶éç½®å°ç¬¬ä¸é¡µ |
| | | queryParams.current = 1; |
| | | queryParams.treeId = data.id; |
| | | getArchiveListData(); |
| | | }; |
| | | const rowClickData = ref({}); // åå¨å½åç¹å»çèç¹æ°æ® |
| | | const archiveDialogs = ref(null); // è¡¨æ ¼ç»ä»¶å¼ç¨ |
| | | // æ°å¢å½æ¡£ |
| | | const add = () => { |
| | |
| | | // ç¡®ä¿ç»ä»¶å¼ç¨åå¨ååè°ç¨æ¹æ³ |
| | | nextTick(() => { |
| | | if (archiveDialogs.value && typeof archiveDialogs.value.initForm === 'function') { |
| | | archiveDialogs.value.initForm(); // é置表å |
| | | archiveDialogs.value.initForm(rowClickData.value); // é置表å |
| | | } |
| | | }); |
| | | } catch (error) { |
| | |
| | | const initTreeDataId = ref(null); |
| | | const fileUploadRef = ref(null); |
| | | const initForm = (val) => { |
| | | initTreeDataId.value = val.value.id || null; // ç¡®ä¿ initTreeDataId åå§å为 null |
| | | initTreeDataId.value = val.id || null; // ç¡®ä¿ initTreeDataId åå§å为 null |
| | | ruleForm.value = {}; |
| | | ruleForm.value.treeId = val.value.id || null; // ç¡®ä¿ treeId åå§å为 null |
| | | ruleForm.value.treeId = val.id || null; // ç¡®ä¿ treeId åå§å为 null |
| | | nextTick(() => { |
| | | fileUploadRef.value.init(); |
| | | }); |
| | |
| | | }); |
| | | return; |
| | | } |
| | | // åé emit äºä»¶ |
| | | |
| | | // å
³éå¯¹è¯æ¡ |
| | | centerDialogVisible.value = false; |
| | | } catch (error) { |
| | | ElMessage({ |
| | |
| | | @selection-change="handleSelectionChange" |
| | | :operations="['edit', 'viewRow']" |
| | | :operationsWidth="200" |
| | | :show-overflow-tooltip="false" |
| | | > |
| | | <!-- åæ®µåç§°åçèªå®ä¹ææ§½ - æ¾ç¤ºä¸ºæ ç¾ --> |
| | | <template |
| | |
| | | import Coal from "./mould/coal.vue"; |
| | | import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue"; |
| | | import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue"; |
| | | import Descriptions from "@/components/dialog/Descriptions.vue"; |
| | | |
| | | // ===== API æå¡å¯¼å
¥ ===== |
| | | import { delSupply, getSupply } from "@/api/basicInformation/supplier.js"; |
| | |
| | | import { |
| | | getCoalFieldList, |
| | | getCoalPlanList, |
| | | delCoalPlan, |
| | | } from "@/api/basicInformation/coalQualityMaintenance"; |
| | | |
| | | import { useDelete } from "@/hooks/useDelete.js"; |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | // ===== ååºå¼ç¶æç®¡ç ===== |
| | | // å¼¹çªæ§å¶ç¶æ |
| | | const showDialog = ref(false); |
| | | const currentViewData = ref({}); // å½åæ¥ççæ°æ® |
| | | |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const form = ref({}); |
| | | const title = ref(""); |
| | |
| | | const getUserList = async () => { |
| | | try { |
| | | const res = await testUserList(); |
| | | console.log("è·åç¨æ·åè¡¨æ°æ®:", res); |
| | | console.log("userMap:", userMap.value); |
| | | if (res && res.data) { |
| | | userList.value = res.data; |
| | | userList.value.forEach((user) => { |
| | | userMap.value[user.userId] = user.username; |
| | | userMap.value[user.userId] = user.nickName; |
| | | }); |
| | | } |
| | | } catch (error) { |
| | |
| | | */ |
| | | const searchPlaceholder = computed(() => { |
| | | const placeholderMap = { |
| | | supplier: "ä¾åºå/è¯å«ç /详ç»å°å", |
| | | customer: "ä¾åºå/è¯å«ç /详ç»å°å", |
| | | coal: "请è¾å
¥æç´¢ä¿¡æ¯", |
| | | coalQualityMaintenance: "请è¾å
¥æç´¢ä¿¡æ¯", |
| | | coalMeiZhiZiDuanWeiHu: "请è¾å
¥æç´¢ä¿¡æ¯", |
| | | supplier: "ä¾åºå/ç»ä¸è¯å«ç /详ç»å°å", |
| | | customer: "ä¾åºå/ç»ä¸è¯å«ç /详ç»å°å", |
| | | coal: "请è¾å
¥ç
¤ç§ä¿¡æ¯", |
| | | coalQualityMaintenance: "请è¾å
¥ç
¤è´¨æ¹æ¡ä¿¡æ¯", |
| | | coalMeiZhiZiDuanWeiHu: "请è¾å
¥ç
¤è´¨å段信æ¯", |
| | | }; |
| | | return placeholderMap[tabName.value] || "请è¾å
¥æç´¢ä¿¡æ¯"; |
| | | }); |
| | |
| | | * æ¹éå é¤å¤ç |
| | | * @description æ¹éå é¤éä¸çè®°å½ |
| | | */ |
| | | const handleDelete = async () => { |
| | | if (selectedRows.value.length === 0) { |
| | | ElMessage.warning("è¯·éæ©è¦å é¤çæ°æ®"); |
| | | return; |
| | | } |
| | | |
| | | const deleteIds = selectedRows.value.map((item) => item.id); |
| | | |
| | | try { |
| | | await ElMessageBox.confirm("ç¡®å®å é¤éä¸çæ°æ®åï¼", "æç¤º", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }); |
| | | |
| | | const deleteApiMap = { |
| | | const deleteApiMap = { |
| | | supplier: delSupply, |
| | | coal: delCoalInfo, |
| | | coalQualityMaintenance: () => { |
| | | throw new Error("delCoalQuality API not imported"); |
| | | }, |
| | | coalQualityMaintenance: delCoalPlan, |
| | | customer: delCustomer, |
| | | coalMeiZhiZiDuanWeiHu: deleteCoalField, |
| | | }; |
| | | |
| | | const deleteApi = deleteApiMap[tabName.value]; |
| | | if (!deleteApi) { |
| | | ElMessage.error("å 餿¥å£æªé
ç½®"); |
| | | return; |
| | | } |
| | | console.log(deleteIds); |
| | | const res = await deleteApi(deleteIds); |
| | | |
| | | if (res.code !== 200 && res.msg !== "æä½æå") { |
| | | ElMessage.error("å é¤å¤±è´¥ï¼" + res.msg); |
| | | return; |
| | | } |
| | | |
| | | ElMessage.success("å 餿å"); |
| | | await getList(); |
| | | } catch (error) { |
| | | if (error.message !== "cancel") { |
| | | console.error("å 餿ä½å¤±è´¥:", error); |
| | | ElMessage.error("å é¤å¤±è´¥ï¼è¯·ç¨ååè¯"); |
| | | } else { |
| | | ElMessage.info("已忶å 餿ä½"); |
| | | } |
| | | } finally { |
| | | selectedRows.value = []; |
| | | } |
| | | }; |
| | | const {handleDeleteBatch :handleDelete} = useDelete({ |
| | | deleteApi: () => deleteApiMap[tabName.value], |
| | | selectedRows: selectedRows, |
| | | getList: () => getList, |
| | | tableData: tableData, |
| | | total: total, |
| | | confirmText: "确认å é¤éä¸çæ°æ®åï¼", |
| | | successText: "å 餿å", |
| | | }) |
| | | |
| | | /** |
| | | * å
³éå¼¹çªå¤ç |
| | |
| | | </el-form-item> |
| | | <el-form-item label="ç»´æ¤äººå§å" prop="maintainerId"> |
| | | <el-input |
| | | :value="userStore.name || ''" |
| | | :value="userStore.nickName || ''" |
| | | placeholder="ç»´æ¤äººå§å" |
| | | disabled |
| | | /> |
| | |
| | | |
| | | <el-form-item class="dialog-footer"> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm">éç½®</el-button> |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm">åæ¶</el-button> |
| | | <el-button type="primary" @click="submitForm"> |
| | | <el-button v-if="addOrEdit === 'add'||addOrEdit.includes('viewRow')" @click="cancelForm">åæ¶</el-button> |
| | | <el-button type="primary" @click="submitForm" v-if="!isViewMode"> |
| | | ç¡®å® |
| | | </el-button> |
| | | </el-form-item> |
| | |
| | | required: true, |
| | | type: Object, |
| | | }); |
| | | // å¨ç»ä»¶æè½½æ¶è·åç¨æ·ä¿¡æ¯ |
| | | onMounted(async () => { |
| | | // 妿store䏿²¡æç¨æ·ä¿¡æ¯ï¼åè·åç¨æ·ä¿¡æ¯ |
| | | if (!userStore.name) { |
| | | try { |
| | | await userStore.getInfo() |
| | | // èªå¨å¡«å
ç»´æ¤äººID |
| | | if (props.addOrEdit === 'add') { |
| | | formData.value.maintainerId = userStore.id |
| | | } |
| | | } catch (error) { |
| | | console.error('è·åç¨æ·ä¿¡æ¯å¤±è´¥:', error) |
| | | } |
| | | } else { |
| | | // èªå¨å¡«å
ç»´æ¤äººID |
| | | if (props.addOrEdit === 'add') { |
| | | formData.value.maintainerId = userStore.id |
| | | } |
| | | } |
| | | }) |
| | | |
| | | const emit = defineEmits(['submit', 'handleBeforeClose', 'update:coalDialogFormVisible']) |
| | | // 表åå¼ç¨ |
| | |
| | | if (!formRef.value) return |
| | | await formRef.value.validate(async (valid, fields) => { |
| | | if (valid) { |
| | | delete formData.value.maintainerName // å 餿¾ç¤ºç¨çåæ®µï¼åªä¿çID |
| | | |
| | | // ç¡®ä¿maintainerIdæå¼ |
| | | if (!formData.value.maintainerId) { |
| | |
| | | emit('update:coalDialogFormVisible', false) |
| | | } |
| | | const rules = reactive({ |
| | | supplierName: [ |
| | | {required: true, message: "请è¾å
¥ä¾è´§ååç§°", trigger: "blur"}, |
| | | ], |
| | | identifyNumber: [ |
| | | {required: true, message: "请æ£ç¡®è¾å
¥çº³ç¨äººè¯å«å·", trigger: "blur"}, |
| | | {min: 17, max: 20, message: "请è¾å
¥17-20ä½çº³ç¨äººè¯å«å·", trigger: "blur"}, |
| | | coal: [ |
| | | {required: true, message: "请è¾å
¥ç
¤ç§åç§°", trigger: "blur"}, |
| | | ], |
| | | }); |
| | | |
| | |
| | | >éç½® |
| | | </el-button |
| | | > |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm" |
| | | <el-button v-if="addOrEdit === 'add' || addOrEdit.includes('viewRow')" @click="cancelForm" |
| | | >åæ¶ |
| | | </el-button |
| | | > |
| | | <el-button type="primary" @click="submitForm"> ç¡®å®</el-button> |
| | | <el-button type="primary" v-if="!isViewMode" @click="submitForm" > ç¡®å®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | |
| | | </el-form-item> |
| | | <el-form-item class="dialog-footer"> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm">éç½®</el-button> |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm">åæ¶</el-button> |
| | | <el-button type="primary" @click="submitForm"> |
| | | <el-button v-if="addOrEdit === 'add' || addOrEdit.includes('viewRow')" @click="cancelForm">åæ¶</el-button> |
| | | <el-button type="primary" v-if="!isViewMode" @click="submitForm"> |
| | | ç¡®å® |
| | | </el-button> |
| | | </el-form-item> |
| | |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm" |
| | | >éç½®</el-button |
| | | > |
| | | <el-button v-if="addOrEdit !== 'edit'" @click="cancelForm" |
| | | <el-button v-if="addOrEdit !== 'edit'||addOrEdit.includes('viewRow')" @click="cancelForm" |
| | | >åæ¶</el-button |
| | | > |
| | | <el-button type="primary" @click="submitForm"> ç¡®å®</el-button> |
| | | <el-button type="primary" @click="submitForm" v-if="!isViewMode"> ç¡®å®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | <style scoped lang="scss"> |
| | | .dashboard { |
| | | padding: 20px; |
| | | background-color: #f5f7fa; |
| | | min-height: 100vh; |
| | | min-height: 91vh; |
| | | box-sizing: border-box; |
| | | } |
| | | |
| | | /* é¡¶é¨ç»è®¡å¡ç */ |
| | |
| | | |
| | | /* è¡¨æ ¼æ ·å¼è°æ´ */ |
| | | .bottom-card.table { |
| | | min-width: 320px; |
| | | width: 100%; |
| | | } |
| | | |
| | | .bottom-card.table .el-table { |
| | |
| | | .bottom-card.table .el-table th { |
| | | padding: 8px 0; |
| | | } |
| | | |
| | | :deep(.el-scrollbar__view){ |
| | | width: 100% !important; |
| | | |
| | | } |
| | | :deep(.el-table__header,){ |
| | | width: 100% !important; |
| | | } |
| | | :deep(.el-table__body,){ |
| | | width: 100% !important; |
| | | } |
| | | /* ååºå¼è®¾è®¡ */ |
| | | @media (max-width: 1200px) { |
| | | .bottom-section { |
| | |
| | | } |
| | | const deleteIds = selectedRows.value.map(item => item.id); |
| | | proxy.$modal.confirm('æ¯å¦ç¡®è®¤å 餿鿰æ®é¡¹ï¼').then(function() { |
| | | return delQrCode(deleteIds) |
| | | if (tabName.value === "task") { |
| | | return delInspectionTask(deleteIds) |
| | | } else { |
| | | return delQrCode(deleteIds) |
| | | } |
| | | }).then(() => { |
| | | handleQuery() |
| | | proxy.$modal.msgSuccess("å 餿å") |
| | |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="åä»·(ä¸å«ç¨)" prop="priceExcludingTax"> |
| | | <el-form-item label="åä»·(å«ç¨)" prop="priceIncludingTax"> |
| | | <el-input |
| | | v-model.number="form.priceExcludingTax" |
| | | placeholder="请è¾å
¥" |
| | | v-model.number="form.priceIncludingTax" |
| | | placeholder="请è¾å
¥å«ç¨åä»·" |
| | | @blur="handlePriceBlur" |
| | | :disabled="isViewMode" |
| | | > |
| | |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="åä»·(å«ç¨)" prop="priceIncludingTax"> |
| | | <el-form-item label="åä»·(ä¸å«ç¨)" prop="priceExcludingTax"> |
| | | <el-input |
| | | v-model.number="form.priceIncludingTax" |
| | | v-model.number="form.priceExcludingTax" |
| | | placeholder="èªå¨è®¡ç®" |
| | | :disabled="isViewMode" |
| | | disabled |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">å
</i> |
| | |
| | | <el-input |
| | | v-model.number="form.totalPriceExcludingTax" |
| | | placeholder="èªå¨è®¡ç®" |
| | | :disabled="isViewMode" |
| | | disabled |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">å
</i> |
| | |
| | | <el-input |
| | | v-model.number="form.totalPriceIncludingTax" |
| | | placeholder="èªå¨è®¡ç®" |
| | | :disabled="isViewMode" |
| | | disabled |
| | | > |
| | | <template v-slot:suffix> |
| | | <i style="font-style: normal">å
</i> |
| | |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç»è®°äºº" prop="registrantId"> |
| | | <el-input v-model="form.registrantId" disabled placeholder="请è¾å
¥"/> |
| | | <el-input :value="match(form.registrantId)" v-model.number="form.registrantId" disabled placeholder="请è¾å
¥"/> |
| | | </el-form-item> |
| | | <el-form-item label="ç»è®°æ¥æ" prop="registrationDate"> |
| | | <el-date-picker |
| | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <!-- éç½®ååæ¶ --> |
| | | <el-button @click="handleClose" v-if="title.includes('æ°å¢')" |
| | | <el-button @click="handleClose" v-if="title.includes('æ°å¢') || title.includes('æ¥ç')" |
| | | >åæ¶ |
| | | </el-button |
| | | > |
| | |
| | | >éç½® |
| | | </el-button |
| | | > |
| | | <el-button type="primary" @click="handleSubmit">确认</el-button> |
| | | <el-button type="primary" v-if="!isViewMode" @click="handleSubmit">确认</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | defineExpose({ |
| | | getDropdownData, |
| | | }); |
| | | // æ°å¼æ ¼å¼åå·¥å
·å½æ° |
| | | const toFixed = (num, precision = 2) => { |
| | | if (isNaN(num) || num === null || num === undefined || num === "") { |
| | | return 0; |
| | | } |
| | | return ( |
| | | Math.floor(parseFloat(num) * Math.pow(10, precision)) / |
| | | Math.pow(10, precision) |
| | | ); |
| | | return Number((Math.floor(parseFloat(num) * Math.pow(10, precision)) / Math.pow(10, precision)).toFixed(precision)); |
| | | }; |
| | | // å«ç¨åä»·è®¡ç® |
| | | const unitPriceWithTax = computed(() => { |
| | | const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0; |
| | | const taxRate = parseFloat(form.value.taxRate) || 0; |
| | | if (!priceExcludingTax || !taxRate) { |
| | | return 0; |
| | | } |
| | | const result = priceExcludingTax * (1 + taxRate / 100); |
| | | return toFixed(result, 2); |
| | | }); |
| | | |
| | | // å«ç¨æ»ä»·è®¡ç® |
| | | const totalUnitPriceWithTax = computed(() => { |
| | | const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0; |
| | | const taxRate = parseFloat(form.value.taxRate) || 0; |
| | | const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0; |
| | | // å®å
¨è·åæ°å¼ |
| | | const safeNumber = (value) => { |
| | | const num = parseFloat(value); |
| | | return isNaN(num) ? 0 : num; |
| | | }; |
| | | |
| | | if (!priceExcludingTax || !taxRate || !purchaseQuantity) { |
| | | return 0; |
| | | } |
| | | // 计ç®é»è¾ - åºäºå«ç¨å价计ç®ä¸å«ç¨ä»·æ ¼ |
| | | const calculatePrices = () => { |
| | | const priceIncludingTax = safeNumber(form.value.priceIncludingTax); // å«ç¨åä»· |
| | | const taxRate = safeNumber(form.value.taxRate); // ç¨ç |
| | | const quantity = safeNumber(form.value.purchaseQuantity); // éè´æ°é |
| | | |
| | | const unitPriceWithTaxValue = priceExcludingTax * (1 + taxRate / 100); |
| | | const result = unitPriceWithTaxValue * purchaseQuantity; |
| | | return toFixed(result, 2); |
| | | }); |
| | | // 1. æ ¹æ®å«ç¨åä»·åç¨ç计ç®ä¸å«ç¨åä»· |
| | | // ä¸å«ç¨åä»· = å«ç¨åä»· / (1 + ç¨ç/100) |
| | | const priceExcludingTax = priceIncludingTax && taxRate |
| | | ? toFixed(priceIncludingTax / (1 + taxRate / 100), 2) |
| | | : 0; |
| | | |
| | | // ä¸å«ç¨æ»ä»·è®¡ç® |
| | | const taxExclusiveTotalPrice = computed(() => { |
| | | const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0; |
| | | const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0; |
| | | // 2. 计ç®ä¸å«ç¨æ»ä»· = ä¸å«ç¨åä»· à æ°é |
| | | const totalPriceExcludingTax = priceExcludingTax && quantity |
| | | ? toFixed(priceExcludingTax * quantity, 2) |
| | | : 0; |
| | | |
| | | if (!purchaseQuantity || !priceExcludingTax) { |
| | | return 0; |
| | | } |
| | | // 3. 计ç®å«ç¨æ»ä»· = å«ç¨åä»· à æ°é |
| | | const totalPriceIncludingTax = priceIncludingTax && quantity |
| | | ? toFixed(priceIncludingTax * quantity, 2) |
| | | : 0; |
| | | |
| | | const result = purchaseQuantity * priceExcludingTax; |
| | | return toFixed(result, 2); |
| | | }); |
| | | // æ´æ°è¡¨åæ°æ® |
| | | form.value.priceExcludingTax = priceExcludingTax; |
| | | form.value.totalPriceExcludingTax = totalPriceExcludingTax; |
| | | form.value.totalPriceIncludingTax = totalPriceIncludingTax; |
| | | }; |
| | | |
| | | // çå¬è®¡ç®å¼ååï¼åæ¥å° form å¯¹è±¡ä¸ |
| | | watch(unitPriceWithTax, (newValue) => { |
| | | form.value.priceIncludingTax = newValue; |
| | | }); |
| | | |
| | | watch(totalUnitPriceWithTax, (newValue) => { |
| | | form.value.totalPriceIncludingTax = newValue; |
| | | }); |
| | | |
| | | watch(taxExclusiveTotalPrice, (newValue) => { |
| | | form.value.totalPriceExcludingTax = newValue; |
| | | }); |
| | | // çå¬è¡¨å对象ååï¼ç¨äºå¤çç¼è¾æ¨¡å¼ä¸çæ°æ®å è½½å宿¶è®¡ç® |
| | | watch( |
| | | () => [form.value.priceIncludingTax, form.value.taxRate, form.value.purchaseQuantity], |
| | | () => { |
| | | // 鲿å¤çï¼é¿å
é¢ç¹è®¡ç® |
| | | nextTick(() => { |
| | | calculatePrices(); |
| | | }); |
| | | }, |
| | | { deep: true } |
| | | ); |
| | | |
| | | const userStore = useUserStore(); |
| | | const userInfo = ref({}); |
| | | |
| | | // å¤çç¨çè¾å
¥æ¡å¤±ç¦ï¼ç¡®ä¿ç²¾åº¦ |
| | | const match = () => { |
| | | return userInfo.value.nickName || "æªç¥ç¨æ·"; |
| | | }; |
| | | // å¤çç¨çè¾å
¥æ¡å¤±ç¦äºä»¶ |
| | | const handleTaxRateBlur = () => { |
| | | if ( |
| | | form.value.taxRate !== null && |
| | | form.value.taxRate !== undefined && |
| | | form.value.taxRate !== "" |
| | | ) { |
| | | if (form.value.taxRate !== null && form.value.taxRate !== undefined && form.value.taxRate !== "") { |
| | | form.value.taxRate = toFixed(parseFloat(form.value.taxRate), 2); |
| | | // watch ä¼èªå¨è§¦å calculatePricesï¼ä¸éè¦æå¨è°ç¨ |
| | | } |
| | | }; |
| | | |
| | | // å¤çä¸å«ç¨åä»·è¾å
¥æ¡å¤±ç¦ï¼ç¡®ä¿ç²¾åº¦ |
| | | // å¤çå«ç¨åä»·è¾å
¥æ¡å¤±ç¦äºä»¶ |
| | | const handlePriceBlur = () => { |
| | | if ( |
| | | form.value.priceExcludingTax !== null && |
| | | form.value.priceExcludingTax !== undefined && |
| | | form.value.priceExcludingTax !== "" |
| | | ) { |
| | | form.value.priceExcludingTax = toFixed( |
| | | parseFloat(form.value.priceExcludingTax), |
| | | 2 |
| | | ); |
| | | if (form.value.priceIncludingTax !== null && form.value.priceIncludingTax !== undefined && form.value.priceIncludingTax !== "") { |
| | | form.value.priceIncludingTax = toFixed(parseFloat(form.value.priceIncludingTax), 2); |
| | | // watch ä¼èªå¨è§¦å calculatePricesï¼ä¸éè¦æå¨è°ç¨ |
| | | } |
| | | }; |
| | | |
| | | // å¤çéè´æ°éè¾å
¥æ¡å¤±ç¦ï¼ç¡®ä¿ç²¾åº¦ |
| | | // å¤çéè´æ°éè¾å
¥æ¡å¤±ç¦äºä»¶ |
| | | const handleQuantityBlur = () => { |
| | | if ( |
| | | form.value.purchaseQuantity !== null && |
| | | form.value.purchaseQuantity !== undefined && |
| | | form.value.purchaseQuantity !== "" |
| | | ) { |
| | | form.value.purchaseQuantity = toFixed( |
| | | parseFloat(form.value.purchaseQuantity), |
| | | 3 |
| | | ); // æ°éä¿ç3ä½å°æ° |
| | | if (form.value.purchaseQuantity !== null && form.value.purchaseQuantity !== undefined && form.value.purchaseQuantity !== "") { |
| | | form.value.purchaseQuantity = toFixed(parseFloat(form.value.purchaseQuantity), 3); // æ°éä¿ç3ä½å°æ° |
| | | // watch ä¼èªå¨è§¦å calculatePricesï¼ä¸éè¦æå¨è°ç¨ |
| | | } |
| | | }; |
| | | |
| | | onMounted(async () => { |
| | | let res = await userStore.getInfo(); |
| | | userInfo.value = res; |
| | | getDropdownData() |
| | | userInfo.value = res.user; |
| | | await getDropdownData(); |
| | | // ç»ä»¶å è½½å®æå触å䏿¬¡è®¡ç® |
| | | calculatePrices(); |
| | | }); |
| | | const rules = { |
| | | supplierName: [ |
| | |
| | | purchaseRegistration, |
| | | getSupplyList, |
| | | getCoalInfoList, |
| | | delPR |
| | | } from "@/api/procureMent"; |
| | | import { useDelete } from "@/hooks/useDelete"; |
| | | |
| | | import useUserStore from "@/store/modules/user"; |
| | | // å¼å
¥åå
¸æ°æ® |
| | |
| | | // 触åreféé¢çæ¹æ³ |
| | | return; |
| | | } |
| | | console.log(userInfo.value) |
| | | // æ°å»ºæ¶åå§å表å |
| | | form.value = { |
| | | supplierName: "", |
| | |
| | | priceIncludingTax: "", |
| | | totalPriceIncludingTax: "", |
| | | taxRate: "", |
| | | registrantId: userInfo.value.userName, |
| | | registrantId: userInfo.value.userId, |
| | | registrationDate: new Date().toISOString().split("T")[0], |
| | | }; |
| | | // æ°å»ºæ¶ä¹éè¦è®¾ç½® copyForm ç¨äºéç½®åè½ |
| | |
| | | addOrEdit.value = "viewRow"; |
| | | handleAddEdit(); |
| | | }; |
| | | const handleDelete = () => { |
| | | if (selectedRows.value.length === 0) { |
| | | ElMessage.warning("è¯·éæ©è¦å é¤çæ°æ®"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm(`ç¡®å®å é¤éä¸çæ°æ®åï¼`, "æç¤º", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | // 模æå é¤æä½ |
| | | tableData.value = tableData.value.filter( |
| | | (item) => !selectedRows.value.includes(item) |
| | | ); |
| | | total.value = tableData.value.length; |
| | | ElMessage.success("å 餿å"); |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.info("已忶å é¤"); |
| | | }); |
| | | }; |
| | | // 使ç¨å é¤ç»åå¼å½æ° - ç®åçæ¬ |
| | | const { handleDeleteBatch: handleDelete } = useDelete({ |
| | | deleteApi: delPR, |
| | | selectedRows, |
| | | tableData, |
| | | total, |
| | | confirmText: "ç¡®å®å é¤éä¸çéè´è®°å½åï¼", |
| | | useLocalUpdate: true |
| | | }); |
| | | const handleDeleteSuccess = (row) => { |
| | | ElMessage.success("å 餿åï¼" + row.supplierName); |
| | | }; |
| | |
| | | getCoalInfoList, |
| | | deleteProductionInventory, |
| | | } from "@/api/production/index.js"; |
| | | import { getSupplyList } from "@/api/procureMent/index.js" |
| | | import {validateFormData, validateNumber, deepClone, createDefaultProductionRow} from "@/utils/production"; |
| | | import {useCoalData} from "./useCoalData"; |
| | | import useUserStore from "@/store/modules/user"; |
| | |
| | | ]; |
| | | |
| | | const formalDatabaseColumns = ref([ |
| | | {prop: "supplierName", label: "ä¾åºååç§°", minwidth: 150 |
| | | // ,formatter: (row) => { |
| | | // console.log(row); |
| | | // return supplierList.value[row.supplierId] || "--"; |
| | | // } |
| | | {prop: "supplierId", label: "ä¾åºååç§°", minwidth: 150 |
| | | ,formatter: (row) => { |
| | | return supplierList.value.find(supplier => supplier.id === row.supplierId)?.supplierName || "--"; |
| | | } |
| | | }, |
| | | {prop: "coalId", label: "ç
¤ç§", minwidth: 60, |
| | | formatter: (row) => { |
| | | // return coalList.value[row.coalId].coal || "--"; |
| | | return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--"; |
| | | } |
| | | }, |
| | |
| | | // è·åé
ç½®æ°æ® |
| | | const handlData = async () => { |
| | | innerVisible.value = true; |
| | | let getSupplier = await getOfficialAll(); |
| | | let OfficialAll = await getOfficialAll(); |
| | | let getSupplierList = await getSupplyList(); |
| | | let getCoalName = await getCoalInfoList(); |
| | | coalList.value = getCoalName.data || []; |
| | | supplierList.value = getSupplier.data || []; |
| | | if (getSupplier.code === 200) { |
| | | formalDatabaseData.value = getSupplier.data; |
| | | supplierList.value = getSupplierList.data || []; |
| | | if (OfficialAll.code === 200) { |
| | | formalDatabaseData.value = OfficialAll.data; |
| | | const existingOfficialIds = tableData.value |
| | | .map((item) => item.officialId) |
| | | .filter((id) => id); |
| | |
| | | <template> |
| | | <div> |
| | | <div class="app-container"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form :inline="true" :model="queryParams" class="search-form"> |
| | | <el-form-item label="æç´¢"> |
| | |
| | | |
| | | .search-form { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | justify-content: flex-start; |
| | | align-items: center; |
| | | margin-bottom: 20px; |
| | | |
| | |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç
¤è´¨æ¹æ¡" prop="qualityPlan"> |
| | | <el-select v-model="form.qualityPlan" placeholder="è¯·éæ©" @change="coalPlanByIdList" clearable> |
| | | <el-form-item label="ç
¤è´¨æ¹æ¡" prop="coalPlanId"> |
| | | <el-select v-model="form.coalPlanId" placeholder="è¯·éæ©" @change="coalPlanByIdList" clearable> |
| | | <el-option |
| | | v-for="dict in qualityPlanOption" |
| | | :key="dict.id" |
| | |
| | | </template> |
| | | </el-dialog> |
| | | <!-- åå¹¶æ°æ®å¼¹æ¡ --> |
| | | <el-dialog title="åå¹¶åºå" v-model="mergeVisible" width="800px"> |
| | | <el-dialog :title="operationType.value === 'edit' ? 'ç¼è¾åºå' : 'åå¹¶åºå'" v-model="mergeVisible" width="800px"> |
| | | <el-form :model="mergeForm" :rules="mergeRules" ref="mergeRef" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="æ»ä»·(ä¸å«ç¨)" prop="totalPriceExcludingTax"> |
| | | <el-input v-model="mergeForm.totalPriceExcludingTax" placeholder="请è¾å
¥æ»ä»·(ä¸å«ç¨)" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç
¤è´¨æ¹æ¡" prop="coalPlanId"> |
| | | <el-select v-model="mergeForm.coalPlanId" placeholder="è¯·éæ©" @change="coalPlanByIdList" clearable> |
| | | <el-option |
| | | v-for="dict in qualityPlanOption" |
| | | :key="dict.id" |
| | | :label="dict.plan" |
| | | :value="dict.id" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | totalPriceIncludingTax: '', |
| | | priceExcludingTax: '', |
| | | totalPriceExcludingTax: '', |
| | | qualityPlan: '', |
| | | coalPlanId: '', |
| | | pId: '', |
| | | }, |
| | | mergeForm: { |
| | |
| | | totalPriceIncludingTax: '', |
| | | priceExcludingTax: '', |
| | | totalPriceExcludingTax: '', |
| | | qualityPlan: '', |
| | | coalPlanId: '', |
| | | pId: '', |
| | | }, |
| | | rules: { |
| | | supplierName: [{ required: true, message: "请è¾å
¥ä¾åºååç§°", trigger: "blur" }], |
| | | coal: [{ required: true, message: "请è¾å
¥ç
¤ç§", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请è¾å
¥åä½", trigger: "blur" }], |
| | | qualityPlan: [{ required: true, message: "è¯·éæ©", trigger: "change" }], |
| | | coalPlanId: [{ required: true, message: "è¯·éæ©", trigger: "change" }], |
| | | }, |
| | | mergeRules: { |
| | | supplierName: [{ required: true, message: "请è¾å
¥ä¾åºååç§°", trigger: "blur" }], |
| | | coal: [{ required: true, message: "请è¾å
¥ç
¤ç§", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请è¾å
¥åä½", trigger: "blur" }], |
| | | qualityPlan: [{ required: true, message: "è¯·éæ©", trigger: "change" }], |
| | | coalPlanId: [{ required: true, message: "è¯·éæ©", trigger: "change" }], |
| | | } |
| | | }) |
| | | |
| | |
| | | } |
| | | // åå¹¶åºåæ°æ®æ¹æ³ |
| | | const mergeRows = (type,row) => { |
| | | coalFieldListOption(); |
| | | getDropdownData() |
| | | coalPlanListOptions() |
| | | mergeVisible.value = true; |
| | | operationType.value = type; |
| | | if (type === 'edit') { |