Explorar el Código

1、修改检查指导书咨询分页bug
2、供应商管理

ezhizao hace 1 año
padre
commit
40423bb2c9

+ 2 - 2
src/api/business/consult.js

@@ -6,8 +6,8 @@ const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
 export function list(data) {
 	return request({
 		url: baseUrl + '/business/consult/list',
-		method: 'post',
-		data: data,
+		method: 'get',
+		params: data,
 	})
 }
 

+ 2 - 2
src/api/business/inspectionInstruction.js

@@ -40,8 +40,8 @@ export function delCategory(id) {
 export function list(data) {
 	return request({
 		url: baseUrl + '/business/inspectionInstruction/list',
-		method: 'post',
-		data: data,
+		method: 'get',
+		params: data,
 	})
 }
 

+ 37 - 32
src/api/business/product.js

@@ -3,48 +3,53 @@ import request from '@/utils/request'
 const baseUrl = import.meta.env.VITE_APP_BASE_API
 // 查询产品管理列表
 export function listProduct(query) {
-  return request({
-    url: baseUrl + '/business/product/list',
-    method: 'get',
-    params: query
-  })
+	return request({
+		url: baseUrl + '/business/product/list',
+		method: 'get',
+		params: query
+	})
 }
 
 // 查询产品管理详细
 export function getProduct(id) {
-  return request({
-    url: baseUrl + '/business/product/getinfo/' + id,
-    method: 'get'
-  })
+	return request({
+		url: baseUrl + '/business/product/getinfo/' + id,
+		method: 'get'
+	})
 }
 
 // 保存产品信息
 export function saveProduct(data) {
-  let _action = ''
-  if (data.id && data.id !== '0') {
-    _action = 'edit'
-    return request({
-      url: baseUrl + '/business/product/' + _action,
-      method: 'put',
-      data: data
-    })
-  }
-  else {
-    _action = 'add'
-    return request({
-      url: baseUrl + '/business/product/' + _action,
-      method: 'post',
-      data: data
-    })
-  }
-
-  
+	let _action = ''
+	if (data.id && data.id !== '0') {
+		_action = 'edit'
+		return request({
+			url: baseUrl + '/business/product/' + _action,
+			method: 'put',
+			data: data
+		})
+	} else {
+		_action = 'add'
+		return request({
+			url: baseUrl + '/business/product/' + _action,
+			method: 'post',
+			data: data
+		})
+	}
 }
 
 // 删除产品管理
 export function delProduct(id) {
-  return request({
-    url: baseUrl + '/business/product/remove/' + id,
-    method: 'delete'
-  })
+	return request({
+		url: baseUrl + '/business/product/remove/' + id,
+		method: 'delete'
+	})
+}
+
+export function getProductsForSupplier(query) {
+	return request({
+		url: baseUrl + '/business/product/getProductsForSupplier',
+		method: 'get',
+		params: query
+	})
 }

+ 54 - 17
src/api/business/supplier.js

@@ -6,48 +6,85 @@ const baseUrl = import.meta.env.VITE_APP_BASE_API
 export function list(data) {
 	return request({
 		url: baseUrl + '/business/supplier/list',
+		method: 'get',
+		params: data
+	})
+}
+
+// 获取外协商信息
+export function getInfo(id) {
+	return request({
+		url: baseUrl + '/business/supplier/getInfo/' + id,
+		method: 'get'
+	})
+}
+
+// 新增外协商
+export function save(data) {
+	return request({
+		url: baseUrl + '/business/supplier/save',
 		method: 'post',
-		data: data,
+		data: data
+	})
+}
+
+// 删除外协商
+export function remove(id) {
+	return request({
+		url: baseUrl + '/business/supplier/remove/' + id,
+		method: 'delete'
 	})
 }
+
 // 查询外协商对应的产品列表
 export function getSupplierProduct(data) {
 	return request({
 		url: baseUrl + '/business/supplier/getSupplierProduct',
-		method: 'post',
-		data: data,
+		method: 'get',
+		params: data
 	})
 }
-// 查询外协商对应的产品对应的工序列表
+
+// 查询外协商对应的产品列表
+// 通过post,是不需要分页的
 export function getSupplierProductProcess(data) {
 	return request({
 		url: baseUrl + '/business/supplier/getSupplierProductProcess',
 		method: 'post',
-		data: data,
+		data: data
 	})
 }
 
-// 获取外协商信息
-export function getInfo(id) {
+// 保存外协商对应的产品列表
+export function saveSupplierProduct(data) {
 	return request({
-		url: baseUrl + '/business/supplier/getInfo/' + id,
-		method: 'get',
+		url: baseUrl + '/business/supplier/saveSupplierProduct',
+		method: 'post',
+		data: data
 	})
 }
 
-// 新增外协商
-export function save(data) {
+// 保存外协商对应的产品对应的工序列表
+export function saveSupplierProductProcess(data) {
 	return request({
-		url: baseUrl + '/business/supplier/save',
+		url: baseUrl + '/business/supplier/saveSupplierProductProcess',
 		method: 'post',
-		data: data,
+		data: data
 	})
 }
 
-// 删除外协商
-export function del(id) {
+// 删除外协商对应的产品列表
+export function removeSupplierProduct(id) {
 	return request({
-		url: baseUrl + '/business/supplier/remove/' + id,
-		method: 'delete',
+		url: baseUrl + '/business/supplier/removeSupplierProduct/' + id,
+		method: 'delete'
+	})
+}
+
+// 删除外协商对应的产品对应的工序列表
+export function removeSupplierProductProcess(id) {
+	return request({
+		url: baseUrl + '/business/supplier/removeSupplierProductProcess/' + id,
+		method: 'delete'
 	})
 }

+ 27 - 18
src/api/business/technologicalProcess.js

@@ -2,34 +2,43 @@ import request from '@/utils/request'
 const baseUrl = '/ezhizao-dms-sys'
 // 查询工艺主表列表
 export function listTechnologicalProcess(query) {
-  return request({
-    url: baseUrl + '/business/technologicalProcess/list',
-    method: 'get',
-    params: query
-  })
+	return request({
+		url: baseUrl + '/business/technologicalProcess/list',
+		method: 'get',
+		params: query
+	})
 }
 
 // 查询工艺主表详细
 export function getTechnologicalprocess(id) {
-  return request({
-    url: baseUrl + '/business/technologicalProcess/' + id,
-    method: 'get'
-  })
+	return request({
+		url: baseUrl + '/business/technologicalProcess/' + id,
+		method: 'get'
+	})
 }
 
 // 新增工艺主表
 export function saveTechnologicalProcess(data) {
-  return request({
-    url: baseUrl + '/business/technologicalProcess/save',
-    method: 'post',
-    data: data
-  })
+	return request({
+		url: baseUrl + '/business/technologicalProcess/save',
+		method: 'post',
+		data: data
+	})
 }
 
 // 删除工艺主表
 export function delTechnologicalProcess(id) {
-  return request({
-    url: baseUrl + '/business/technologicalProcess/' + id,
-    method: 'delete'
-  })
+	return request({
+		url: baseUrl + '/business/technologicalProcess/' + id,
+		method: 'delete'
+	})
+}
+// 查询工艺主表列表,用于供应商管理中的工序配置
+export function getTechnologicalForSupplier(data) {
+	console.log(data)
+	return request({
+		url: baseUrl + '/business/technologicalProcess/getTechnologicalForSupplier',
+		method: 'post',
+		data: data
+	})
 }

+ 32 - 23
src/api/business/technologicalProcessDetail.js

@@ -3,41 +3,50 @@ import request from '@/utils/request'
 const baseUrl = import.meta.env.VITE_APP_BASE_API
 // 查询工艺从表列表
 export function listTechnologicalProcessDetail(query) {
-  return request({
-    url: baseUrl + '/base/technologicalProcessDetail/list',
-    method: 'get',
-    params: query
-  })
+	return request({
+		url: baseUrl + '/base/technologicalProcessDetail/list',
+		method: 'get',
+		params: query
+	})
 }
 
 // 查询工艺从表详细
 export function getTechnologicalProcessDetail(id) {
-  return request({
-    url: baseUrl + '/base/technologicalProcessDetail/' + id,
-    method: 'get'
-  })
+	return request({
+		url: baseUrl + '/base/technologicalProcessDetail/' + id,
+		method: 'get'
+	})
 }
 // 新增工序(单条保存)
 export function saveSingleTechnologicalProcessDetail(data) {
-  return request({
-    url: baseUrl + '/base/technologicalProcessDetail/singleSave',
-    method: 'post',
-    data: data
-  })
+	return request({
+		url: baseUrl + '/base/technologicalProcessDetail/singleSave',
+		method: 'post',
+		data: data
+	})
 }
 // 新增工艺从表
 export function saveTechnologicalProcessDetail(data) {
-  return request({
-    url: baseUrl + '/base/technologicalProcessDetail/save',
-    method: 'post',
-    data: data
-  })
+	return request({
+		url: baseUrl + '/base/technologicalProcessDetail/save',
+		method: 'post',
+		data: data
+	})
 }
 
 // 删除工艺从表
 export function delTechnologicalProcessDetail(id) {
-  return request({
-    url: baseUrl + '/base/technologicalProcessDetail/' + id,
-    method: 'delete'
-  })
+	return request({
+		url: baseUrl + '/base/technologicalProcessDetail/' + id,
+		method: 'delete'
+	})
+}
+
+// 获取工序,用于供应商管理中的相关工序的配置
+export function getProcessesForSupplier(data) {
+	return request({
+		url: baseUrl + '/base/technologicalProcessDetail/getProcessesForSupplier',
+		method: 'post',
+		data: data
+	})
 }

+ 72 - 101
src/views/business/product/DialogProcessChoice.vue

@@ -1,69 +1,41 @@
 <template>
-  <el-dialog title="添加工序" v-model="visible" width="800px" height="400px"   @close="close" append-to-body draggable>
-    <el-form ref="dialogForm" class="master-container" :model="queryParams" style="align-items: center;" >
-      <div style="display: flex;">
-        <el-form-item label="工序编码:" prop="processCode" label-width="100px" style="margin-top: 20px;">
-          <el-input
-            v-model.trim="queryParams.processCode"
-            type="text"
-            @keydown.enter.prevent
-            style="width: 180px"
-            placeholder="请输入工序编码"
-            :clearable="true"
-            @keyup.enter="handleSearch"
-          />
-        </el-form-item>
-        <el-form-item label="工序简称:" prop="processAlias" label-width="100px" style="margin-top: 20px;">
-          <el-input
-            v-model.trim="queryParams.processAlias"
-            type="text"
-            @keydown.enter.prevent
-            style="width: 180px"
-            placeholder="请输入工序简称"
-            :clearable="true"
-            @keyup.enter="handleSearch"
-          />
-        </el-form-item>
-        <el-form-item label-width="20px" style="margin-top: 20px;">
-          <el-button type="info" icon="Search" @click="handleSearch">搜索</el-button>
-        </el-form-item>
-      </div>
-    </el-form>
+	<el-dialog title="添加工序" v-model="visible" width="800px" height="400px" @close="close" append-to-body draggable>
+		<el-form ref="dialogForm" class="master-container" :model="queryParams" style="align-items: center">
+			<div style="display: flex">
+				<el-form-item label="工序编码:" prop="processCode" label-width="100px" style="margin-top: 20px">
+					<el-input v-model.trim="queryParams.processCode" type="text" @keydown.enter.prevent style="width: 180px" placeholder="请输入工序编码" :clearable="true" @keyup.enter="handleSearch" />
+				</el-form-item>
+				<el-form-item label="工序简称:" prop="processAlias" label-width="100px" style="margin-top: 20px">
+					<el-input v-model.trim="queryParams.processAlias" type="text" @keydown.enter.prevent style="width: 180px" placeholder="请输入工序简称" :clearable="true" @keyup.enter="handleSearch" />
+				</el-form-item>
+				<el-form-item label-width="20px" style="margin-top: 20px">
+					<el-button type="info" icon="Search" @click="handleSearch">搜索</el-button>
+				</el-form-item>
+			</div>
+		</el-form>
 
-    <el-table
-      ref="dialogTable"
-      :data="processList"
-      :row-key="getRowKey"
-      size="small"
-      v-loading="loading"
-      border
-      height="370px"
-      header-row-class-name="list-header-row"
-      row-class-name="list-row"
-      @selection-change="handleSelectionChange"
-    >
-      <el-table-column type="selection" width="40" align="center" :reserve-selection="true" />
-      <el-table-column type="index" label="行号" width="50" align="center" />
-      <el-table-column label="工序编码" align="center" prop="processCode" />
-      <el-table-column label="工序简称" align="center" prop="processAlias" />
-      <el-table-column label="工序状态" align="center" prop="status">
-        <template #default="scope">
-          <dict-tag :options="process_status" :value="scope.row.status" />
-        </template>
-      </el-table-column>
-    </el-table>
-    <!-- 分页 -->
-    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
-    <template #footer>
-      <div class="dialog-footer">
-        <el-button type="primary" icon="Check" :disabled="selections.length === 0" @click="handleMultipleSelected">保存</el-button>
-        <el-button icon="Close" @click="close">取 消</el-button>
-      </div>
-    </template>
-  </el-dialog>
+		<el-table ref="dialogTable" :data="processList" :row-key="getRowKey" size="small" v-loading="loading" border height="370px" header-row-class-name="list-header-row" row-class-name="list-row" @selection-change="handleSelectionChange">
+			<el-table-column type="selection" width="40" align="center" :reserve-selection="true" />
+			<el-table-column type="index" label="行号" width="50" align="center" />
+			<el-table-column label="工序编码" align="center" prop="processCode" />
+			<el-table-column label="工序简称" align="center" prop="processAlias" />
+			<el-table-column label="工序状态" align="center" prop="status">
+				<template #default="scope">
+					<dict-tag :options="process_status" :value="scope.row.status" />
+				</template>
+			</el-table-column>
+		</el-table>
+		<!-- 分页 -->
+		<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+		<template #footer>
+			<div class="dialog-footer">
+				<el-button type="primary" icon="Check" :disabled="selections.length === 0" @click="handleMultipleSelected">保存</el-button>
+				<el-button icon="Close" @click="close">取 消</el-button>
+			</div>
+		</template>
+	</el-dialog>
 </template>
 <script setup>
-import { ref } from '@vue/reactivity'
 import { listProcess } from '@/api/business/process'
 const { proxy } = getCurrentInstance()
 /** 字典数组区 */
@@ -71,10 +43,10 @@ const { process_status } = proxy.useDict('process_status')
 /** 工序变量 */
 const total = ref(0)
 const props = defineProps({
-  multipleSelected: {
-    type: Function,
-    default: null
-  }
+	multipleSelected: {
+		type: Function,
+		default: null
+	}
 })
 
 const { multipleSelected } = toRefs(props)
@@ -82,81 +54,80 @@ const processList = ref([])
 const visible = ref(false)
 const loading = ref(false)
 const data = reactive({
-  queryParams: {
-    pageSize: 10,
-    pageNum: 1
-  }
+	queryParams: {
+		pageSize: 10,
+		pageNum: 1
+	}
 })
 const selections = ref([])
 const { queryParams } = toRefs(data)
 
 /** 获取行 id */
 function getRowKey(row) {
-  return row.id
+	return row.id
 }
 
 /**
  * 对话框打开 事件
  */
 function open() {
-  visible.value = true
-  getList()
+	visible.value = true
+	getList()
 }
 
 /**
  * 对话框关闭 事件
  */
 function close() {
-  proxy.$refs.dialogForm.resetFields()
-  proxy.$refs.dialogTable.clearSelection()
-  queryParams.value.pageNum = 1
-  visible.value = false
+	proxy.$refs.dialogForm.resetFields()
+	proxy.$refs.dialogTable.clearSelection()
+	queryParams.value.pageNum = 1
+	visible.value = false
 }
 
 /**
  * 加载数据
  */
 function getList() {
-  loading.value = true
-  queryParams.value.status = 'NA'
-  listProcess(queryParams.value).then((res) => {
-    processList.value = res.rows
-    total.value = res.total
-    loading.value = false
-  })
+	loading.value = true
+	queryParams.value.status = 'NA'
+	listProcess(queryParams.value).then((res) => {
+		processList.value = res.rows
+		total.value = res.total
+		loading.value = false
+	})
 }
 
 /**
  * 列表checkbox列选择 事件
  */
 function handleSelectionChange(selection) {
-  selections.value = selection
+	selections.value = selection
 }
 
-
 /**  搜索 事件 */
 function handleSearch(type) {
-  if (type && type === 'clear') {
-    queryParams.value = {
-      processCode:'',
-      processAlias: '',
-      total: 0,
-      pageSize: 10,
-      pageNum: 1
-    }
-  }
-  getList()
+	if (type && type === 'clear') {
+		queryParams.value = {
+			processCode: '',
+			processAlias: '',
+			total: 0,
+			pageSize: 10,
+			pageNum: 1
+		}
+	}
+	getList()
 }
 /** 多选事件 */
 function handleMultipleSelected() {
-  if (multipleSelected.value) {
-    multipleSelected.value(selections.value)
-  }
-  close()
+	if (multipleSelected.value) {
+		multipleSelected.value(selections.value)
+	}
+	close()
 }
 
 defineExpose({
-  open
+	open
 })
 </script>
 <style scoped></style>

+ 3 - 3
src/views/business/product/index.vue

@@ -211,7 +211,7 @@ const detailsRow = {
 	productCode: undefined,
 	productShaftCategory: undefined,
 	productShaftCategoryName: undefined,
-	productDescription: undefined,
+	productDescription: undefined
 }
 /** 工序变量 */
 const technologicalprocessDetailList = ref([])
@@ -227,7 +227,7 @@ const queryParams = ref({
 	code: '',
 	name: '',
 	combinedValue: null,
-	productCode: '',
+	productCode: ''
 })
 
 /***********************  方法区  ****************************/
@@ -415,7 +415,7 @@ const getTechnologicalProcessDetails = () => {
 	} else {
 		technologicalprocessDetailLoading.value = true
 		listTechnologicalProcessDetail({
-			technologicalProcessId: currentTechnologicalProcess.value.id,
+			technologicalProcessId: currentTechnologicalProcess.value.id
 		}).then((res) => {
 			technologicalprocessDetailList.value = res.rows
 			technologicalprocessDetailLoading.value = false

+ 155 - 0
src/views/business/supplier/DialogProcesses.vue

@@ -0,0 +1,155 @@
+<template>
+	<el-dialog title="添加工序" v-model="visible" width="800px" height="400px" @close="close" append-to-body draggable>
+		<el-form ref="dialogForm" class="master-container" :model="queryParams" style="align-items: center">
+			<div style="display: flex">
+				<el-form-item label="工艺版本:" prop="technologyVersion" label-width="96px" style="margin-top: 20px">
+					<el-select v-model="queryParams.technologyVersion" placeholder="请选择" style="width: 72px">
+						<el-option
+							v-for="item in technologyVersions"
+							:key="item.technologyVersion"
+							:label="item.technologyVersion"
+							:value="item.technologyVersion"
+						/>
+					</el-select>
+				</el-form-item>
+				<el-form-item label="工序名称:" prop="processAlias" label-width="160px" style="margin-top: 20px">
+					<el-input
+						v-model.trim="queryParams.processAlias"
+						type="text"
+						@keydown.enter.prevent
+						style="width: 180px"
+						placeholder="请输入关键字"
+						:clearable="true"
+						@keyup.enter="handleSearch"
+					/>
+				</el-form-item>
+				<el-form-item label-width="20px" style="margin-top: 20px">
+					<el-button type="info" icon="Search" @click="handleSearch">搜索</el-button>
+				</el-form-item>
+			</div>
+		</el-form>
+
+		<el-table
+			ref="dialogTable"
+			:data="processList"
+			size="small"
+			v-loading="loading"
+			border
+			height="370px"
+			@selection-change="handleSelectionChange"
+		>
+			<el-table-column type="selection" width="40" align="center" />
+			<el-table-column type="index" label="行号" width="50" align="center" />
+			<el-table-column label="工序编码" align="center" prop="processCode" />
+			<el-table-column label="工序简称" align="center" prop="processAlias" />
+		</el-table>
+		<!-- 分页 -->
+		<pagination
+			v-show="total > 0"
+			:total="total"
+			v-model:page="queryParams.pageNum"
+			v-model:limit="queryParams.pageSize"
+			@pagination="getList"
+		/>
+		<template #footer>
+			<div class="dialog-footer">
+				<el-button type="primary" icon="Check" :disabled="selections.length === 0" @click="handleMultipleSelected"
+					>保存</el-button
+				>
+				<el-button icon="Close" @click="close">取 消</el-button>
+			</div>
+		</template>
+	</el-dialog>
+</template>
+<script setup>
+import { getTechnologicalForSupplier } from '@/api/business/technologicalProcess'
+import { getProcessesForSupplier } from '@/api/business/technologicalProcessDetail'
+const { proxy } = getCurrentInstance()
+/** 工序变量 */
+const total = ref(0)
+const props = defineProps({
+	multipleSelected: {
+		type: Function,
+		default: null
+	},
+	productId: {
+		type: String,
+		default: ''
+	}
+})
+
+const { multipleSelected, productId } = toRefs(props)
+const processList = ref([])
+const visible = ref(false)
+const loading = ref(false)
+const queryParams = ref({
+	productId: '',
+	technologyVersion: '',
+	processAlias: '',
+	pageNum: 1,
+	pageSize: 10
+})
+const technologyVersions = ref([])
+const selections = ref([])
+
+/**
+ * 对话框打开 事件
+ */
+function open() {
+	visible.value = true
+	getList()
+}
+
+/**
+ * 对话框关闭 事件
+ */
+function close() {
+	proxy.$refs.dialogForm.resetFields()
+	proxy.$refs.dialogTable.clearSelection()
+	queryParams.value.pageNum = 1
+	visible.value = false
+}
+
+/**
+ * 加载数据
+ */
+function getList() {
+	loading.value = true
+	queryParams.value.productId = productId.value
+	getTechnologicalForSupplier({ productId: queryParams.value.productId }).then((res) => {
+		technologyVersions.value = res.data
+		if (technologyVersions.value.length > 0) {
+			queryParams.value.technologyVersion = technologyVersions.value[0].technologyVersion
+			getProcessesForSupplier(queryParams.value).then((res1) => {
+				processList.value = res1.data
+				loading.value = false
+			})
+		} else {
+			loading.value = false
+		}
+	})
+}
+
+/**
+ * 列表checkbox列选择 事件
+ */
+function handleSelectionChange(selection) {
+	selections.value = selection
+}
+
+/**  搜索 事件 */
+function handleSearch() {
+	getList()
+}
+/** 多选事件 */
+function handleMultipleSelected() {
+	if (multipleSelected.value) {
+		multipleSelected.value(selections.value)
+	}
+	close()
+}
+
+defineExpose({
+	open
+})
+</script>

+ 137 - 0
src/views/business/supplier/DialogProducts.vue

@@ -0,0 +1,137 @@
+<template>
+	<el-dialog title="添加产品" v-model="visible" width="800px" height="400px" @close="close" append-to-body draggable>
+		<el-form ref="dialogForm" class="master-container" :model="queryParams" style="align-items: center">
+			<div style="display: flex">
+				<el-form-item label="产品描述:" prop="description" label-width="104px" style="margin-top: 20px">
+					<el-input
+						v-model.trim="queryParams.description"
+						type="text"
+						@keydown.enter.prevent
+						style="width: 320px"
+						placeholder="请输入关键字"
+						:clearable="true"
+						@keyup.enter="handleSearch"
+					/>
+				</el-form-item>
+				<el-form-item label-width="20px" style="margin-top: 20px">
+					<el-button type="info" icon="Search" @click="handleSearch">搜索</el-button>
+				</el-form-item>
+			</div>
+		</el-form>
+
+		<el-table
+			ref="dialogTable"
+			:data="productList"
+			size="small"
+			v-loading="loading"
+			border
+			height="370px"
+			@selection-change="handleSelectionChange"
+		>
+			<el-table-column type="selection" width="40" align="center" />
+			<el-table-column type="index" label="行号" width="50" align="center" />
+			<el-table-column label="料号" align="center" prop="productCode" width="120" />
+			<el-table-column label="产品描述" align="center" prop="description" />
+		</el-table>
+		<!-- 分页 -->
+		<pagination
+			v-show="total > 0"
+			:total="total"
+			v-model:page="queryParams.pageNum"
+			v-model:limit="queryParams.pageSize"
+			@pagination="getList"
+		/>
+		<template #footer>
+			<div class="dialog-footer">
+				<el-button type="primary" icon="Check" :disabled="selections.length === 0" @click="handleMultipleSelected"
+					>保存</el-button
+				>
+				<el-button icon="Close" @click="close">取 消</el-button>
+			</div>
+		</template>
+	</el-dialog>
+</template>
+<script setup>
+import { getProductsForSupplier } from '@/api/business/product'
+const { proxy } = getCurrentInstance()
+/** 字典数组区 */
+const { process_status } = proxy.useDict('process_status')
+/** 工序变量 */
+const total = ref(0)
+const props = defineProps({
+	multipleSelected: {
+		type: Function,
+		default: null
+	},
+	supplierId: {
+		type: String,
+		default: ''
+	}
+})
+
+const { multipleSelected } = toRefs(props)
+const productList = ref([])
+const visible = ref(false)
+const loading = ref(false)
+const queryParams = ref({
+	supplierId: '',
+	description: '',
+	pageNum: 1,
+	pageSize: 10
+})
+const selections = ref([])
+
+/**
+ * 对话框打开 事件
+ */
+function open() {
+	visible.value = true
+	getList()
+}
+
+/**
+ * 对话框关闭 事件
+ */
+function close() {
+	proxy.$refs.dialogForm.resetFields()
+	proxy.$refs.dialogTable.clearSelection()
+	queryParams.value.pageNum = 1
+	visible.value = false
+}
+
+/**
+ * 加载数据
+ */
+function getList() {
+	loading.value = true
+	queryParams.value.supplierId = props.supplierId
+	getProductsForSupplier(queryParams.value).then((res) => {
+		productList.value = res.rows
+		total.value = res.total
+		loading.value = false
+	})
+}
+
+/**
+ * 列表checkbox列选择 事件
+ */
+function handleSelectionChange(selection) {
+	selections.value = selection
+}
+
+/**  搜索 事件 */
+function handleSearch() {
+	getList()
+}
+/** 多选事件 */
+function handleMultipleSelected() {
+	if (multipleSelected.value) {
+		multipleSelected.value(selections.value)
+	}
+	close()
+}
+
+defineExpose({
+	open
+})
+</script>

+ 355 - 34
src/views/business/supplier/index.vue

@@ -5,10 +5,24 @@
 			<el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
 				<el-form-item class="section-title" label="外协商管理" />
 				<el-form-item label="外协商名称:">
-					<el-input placeholder="请输入关键字" v-model.trim="queryParams.name" style="width: 120px" clearable @keyup.enter="handleQuery" @keydown.enter.prevent />
+					<el-input
+						placeholder="请输入关键字"
+						v-model.trim="queryParams.name"
+						style="width: 120px"
+						clearable
+						@keyup.enter="handleQuery"
+						@keydown.enter.prevent
+					/>
 				</el-form-item>
 				<el-form-item label="助记码:">
-					<el-input placeholder="请输入关键字" v-model.trim="queryParams.mnemonicCode" style="width: 120px" clearable @keyup.enter="handleQuery" @keydown.enter.prevent />
+					<el-input
+						placeholder="请输入关键字"
+						v-model.trim="queryParams.mnemonicCode"
+						style="width: 120px"
+						clearable
+						@keyup.enter="handleQuery"
+						@keydown.enter.prevent
+					/>
 				</el-form-item>
 				<el-form-item>
 					<el-button type="info" icon="Search" @click="handleQuery">搜索</el-button>
@@ -17,7 +31,15 @@
 			<!-- 列表区 -->
 			<div class="el-table-container">
 				<div class="el-table-inner-container">
-					<el-table ref="dataTable" v-loading="loading" border :data="supplierList" highlight-current-row height="100%">
+					<el-table
+						ref="supplierTable"
+						v-loading="loading"
+						border
+						:data="supplierList"
+						highlight-current-row
+						height="100%"
+						@current-change="handleCurrentSupplierChange"
+					>
 						<el-table-column type="index" label="行号" width="50" align="center" />
 						<el-table-column label="外协商名称" width="320" align="center" prop="name" />
 						<el-table-column label="助记码" width="120" align="center" prop="productDescription" />
@@ -30,8 +52,22 @@
 						<el-table-column label="备注" align="center" prop="remark" />
 						<el-table-column label="操作" width="132" align="center">
 							<template #default="scope">
-								<el-button v-hasPermi="['system:supplier:edit']" link type="warning" icon="Edit" @click="handleEdit(scope.row)">编辑</el-button>
-								<el-button v-hasPermi="['system:supplier:remove']" link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
+								<el-button
+									v-hasPermi="['system:supplier:edit']"
+									link
+									type="warning"
+									icon="Edit"
+									@click="handleEdit(scope.row)"
+									>编辑</el-button
+								>
+								<el-button
+									v-hasPermi="['system:supplier:remove']"
+									link
+									type="danger"
+									icon="Delete"
+									@click="handleDelete(scope.row)"
+									>删除</el-button
+								>
 							</template>
 						</el-table-column>
 					</el-table>
@@ -39,47 +75,150 @@
 			</div>
 		</section>
 		<!-- 分页 -->
-		<pagination v-show="supplierTotal > 0" :total="supplierTotal" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+		<pagination
+			v-show="supplierTotal > 0"
+			:total="supplierTotal"
+			v-model:page="queryParams.pageNum"
+			v-model:limit="queryParams.pageSize"
+			@pagination="getList"
+		/>
 
 		<section class="list-part-container row-container" style="flex: 1">
-			<section class="list-part-container" style="flex: 1">
+			<section class="list-part-container" style="flex: 2">
 				<!-- 下边页面开始 -->
 				<el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
 					<el-form-item class="section-title" label="产品" />
+					<el-form-item label="产品描述:">
+						<el-input
+							placeholder="请输入关键字"
+							v-model.trim="queryParams.productDescription"
+							style="width: 120px"
+							clearable
+							@keyup.enter="handleQuery"
+							@keydown.enter.prevent
+						/>
+					</el-form-item>
 					<el-form-item>
-						<el-button type="primary" icon="Plus" @click="handleAddProduct" :disabled="!currentSupplier.id">添加产品</el-button>
+						<el-button type="info" icon="Search" @click="handleQueryProducts">搜索</el-button>
+						<el-button
+							type="primary"
+							icon="Plus"
+							@click="handleShowProductsDialog(null)"
+							:disabled="!currentSupplier.id"
+							>添加产品</el-button
+						>
 					</el-form-item>
 				</el-form>
 				<div class="el-table-container">
 					<div class="el-table-inner-container">
-						<el-table ref="technologicalProcessTable" :data="supplierProductList ? supplierProductList : []" v-loading="supplierProductLoading" highlight-current-row height="100%" size="small" header-row-class-name="list-header-row" @current-change="handleCurrentProductChange">
+						<el-table
+							ref="productTable"
+							:data="supplierProductList ? supplierProductList : []"
+							v-loading="supplierProductLoading"
+							highlight-current-row
+							height="100%"
+							size="small"
+							header-row-class-name="list-header-row"
+							@current-change="handleCurrentProductChange"
+						>
 							<el-table-column type="index" label="行号" width="50" align="center" />
+							<el-table-column label="料号" width="120" align="center" prop="productCode" />
 							<el-table-column label="产品描述" align="center" prop="productDescription" />
 							<el-table-column label="操作" width="72px" align="center">
 								<template #default="scope">
-									<el-button link type="danger" icon="Delete" @click="handleDelProduct(scope.row, scope.$index)">删除</el-button>
+									<el-button link type="danger" icon="Delete" @click="handleDelProduct(scope.row)">删除</el-button>
 								</template>
 							</el-table-column>
 						</el-table>
 					</div>
 				</div>
+				<!-- 分页 -->
+				<pagination
+					v-show="productTotal > 0"
+					:total="productTotal"
+					v-model:page="queryProductParams.pageNum"
+					v-model:limit="queryProductParams.pageSize"
+					@pagination="getCurrentSupplierProduct"
+				/>
 			</section>
-			<section class="list-part-container" style="flex: 1">
-				<el-form class="list-search-container list-search-container-child" :model="queryParams" ref="queryRef" :inline="true">
+			<section class="list-part-container" style="flex: 3">
+				<el-form
+					class="list-search-container list-search-container-child"
+					:model="queryParams"
+					ref="queryRef"
+					:inline="true"
+				>
 					<el-form-item class="section-title" label="外协工序" />
 					<el-form-item>
-						<el-button type="primary" icon="Plus" @click="handleAddProcess" :disabled="!currentProduct.id">添加工序</el-button>
+						<el-button
+							type="primary"
+							icon="Plus"
+							@click="handleShowProcessesDialog"
+							:disabled="!currentProduct.id || processEditStatus"
+						>
+							添加工序
+						</el-button>
+						<el-button
+							v-if="!processEditStatus"
+							type="warning"
+							icon="Edit"
+							:disabled="!currentProduct.id || supplierProductProcessList.length === 0"
+							@click="processEditStatus = true"
+						>
+							编辑
+						</el-button>
+						<template v-if="processEditStatus">
+							<el-button type="success" icon="Finished" @click="handleSaveProcess">保存</el-button>
+							<el-button type="danger" icon="Close" @click="processEditStatus = false">取消编辑</el-button>
+						</template>
 					</el-form-item>
 				</el-form>
 				<div class="el-table-container">
 					<div class="el-table-inner-container">
-						<el-table :data="supplierProductProcessList" v-loading="supplierProductProcessLoading" highlight-current-row height="100%">
+						<el-table
+							:data="supplierProductProcessList"
+							v-loading="supplierProductProcessLoading"
+							highlight-current-row
+							height="100%"
+						>
 							<el-table-column type="index" label="行号" width="50" align="center" />
-							<el-table-column label="工序编码" align="center" prop="processCode" />
-							<el-table-column label="工序简称" align="center" prop="processAlias" />
-							<el-table-column label="操作" width="72px" align="center">
+							<el-table-column label="工序编码" width="120" align="center" prop="processCode" />
+							<el-table-column label="工序简称" width="120" align="center" prop="processAlias" />
+							<el-table-column label="结算方式" width="120" align="center" prop="settlementType">
 								<template #default="scope">
-									<el-button link type="danger" icon="Delete" @click="handleDelProcess(scope.row, scope.$index)">删除</el-button>
+									<el-select v-if="processEditStatus" v-model="scope.row.settlementType" clearable placeholder="请选择">
+										<el-option
+											v-for="dict in settlement_type"
+											:key="dict.value"
+											:label="dict.label"
+											:value="dict.value - 0"
+										/>
+									</el-select>
+									<dict-tag v-else :options="settlement_type" :value="scope.row.settlementType" />
+								</template>
+							</el-table-column>
+							<el-table-column label="单价(元)" width="120" align="center" prop="price">
+								<template #default="scope">
+									<el-input-number
+										v-if="processEditStatus"
+										v-model="scope.row.price"
+										:precision="8"
+										:min="0.0"
+										:step="0.00000001"
+										controls-position="right"
+									/>
+									<span v-else>{{ scope.row.price }}</span>
+								</template>
+							</el-table-column>
+							<el-table-column label="备注" align="center" prop="remark">
+								<template #default="scope">
+									<el-input v-if="processEditStatus" v-model="scope.row.remark" />
+									<span v-else>{{ scope.row.remark }}</span>
+								</template>
+							</el-table-column>
+							<el-table-column label="操作" width="64px" align="center">
+								<template #default="scope">
+									<el-button link type="danger" icon="Delete" @click="handleDelProcess(scope.row)">删除</el-button>
 								</template>
 							</el-table-column>
 						</el-table>
@@ -87,61 +226,243 @@
 				</div>
 			</section>
 		</section>
+
+		<dialog-products ref="productsRef" :supplier-id="currentSupplier.id" :multiple-selected="handleProductSelected" />
+		<dialog-processes
+			ref="processesRef"
+			:product-id="currentProduct.productId"
+			:multiple-selected="handleProcessSelected"
+		/>
 	</div>
 </template>
 
 <script setup>
-import { list, save } from '@/api/business/supplier'
+import {
+	list,
+	save,
+	remove,
+	getSupplierProduct,
+	saveSupplierProduct,
+	removeSupplierProduct,
+	getSupplierProductProcess,
+	saveSupplierProductProcess,
+	removeSupplierProductProcess
+} from '@/api/business/supplier'
+import dialogProducts from './DialogProducts'
+import dialogProcesses from './DialogProcesses'
 const { proxy } = getCurrentInstance()
 const { delivery_method } = proxy.useDict('delivery_method')
+const { settlement_type } = proxy.useDict('settlement_type')
 
 /** 外协商查询对象 */
 const queryParams = ref({
 	name: '',
 	mnemonicCode: '',
 	pageNum: 1,
-	pageSize: 10,
+	pageSize: 10
+})
+/** 产品查询对象 */
+const queryProductParams = ref({
+	supplierId: '0',
+	productDescription: '',
+	pageNum: 1,
+	pageSize: 10
+})
+/** 产品工序查询对象 */
+const queryProductProcessParams = ref({
+	supplierId: '0',
+	productId: '0',
+	pageNum: 1,
+	pageSize: 10
 })
 /** 外协商变量 */
+const loading = ref(false)
+const supplierTable = ref(null)
 const supplierList = ref([])
+const supplierTotal = ref(0)
 const currentSupplier = ref({})
 
+const supplierProductLoading = ref(false)
+const productTable = ref(null)
 const supplierProductList = ref([])
+const productTotal = ref(0)
 const currentProduct = ref({})
 
+const supplierProductProcessLoading = ref(false)
 const supplierProductProcessList = ref([])
 const currentProcess = ref({})
-
-const loading = ref(false)
-const supplierProductLoading = ref(false)
-const supplierProductProcessLoading = ref(false)
-
-const supplierTotal = ref(0)
+const processEditStatus = ref(false)
 
 /***********************  方法区  ***********************/
 /** 查询外协商管理列表 */
-function getList() {
+const getList = () => {
 	loading.value = true
 	list(queryParams.value).then((res) => {
 		supplierList.value = res.rows
 		supplierTotal.value = res.total
 		loading.value = false
+		if (supplierList.value.length > 0) {
+			proxy.$refs.supplierTable.setCurrentRow(supplierList.value[0])
+		}
 	})
 }
 /** 外协商搜索按钮操作 */
-function handleQuery() {
+const handleQuery = () => {
 	queryParams.value.pageNum = 1
 	getList()
 }
 
-/** 外协商修改按钮操作 */
-function handleShowSupplierForm(row) {
-	proxy.$refs.deptRef.open(row)
+/**
+ * 外协商的 current change 事件
+ */
+const handleCurrentSupplierChange = (row) => {
+	if (row) {
+		currentSupplier.value = row
+		getCurrentSupplierProduct()
+	}
 }
 
-const handleAddProduct = () => {}
-const handleCurrentProductChange = () => {}
-const handleAddProcess = () => {}
+/**************************************** 产品相关 ****************************************/
+/** 产品打开对话框方法 */
+const handleShowProductsDialog = () => {
+	proxy.$refs.productsRef.open()
+}
+
+const handleQueryProducts = () => {
+	getCurrentSupplierProduct()
+}
+const getCurrentSupplierProduct = () => {
+	supplierProductLoading.value = true
+	queryProductParams.value.supplierId = currentSupplier.value.id
+	getSupplierProduct(queryProductParams.value).then((res) => {
+		supplierProductList.value = res.rows
+		productTotal.value = res.total
+		if (supplierProductList.value.length > 0) {
+			currentProduct.value = supplierProductList.value[0]
+			proxy.$refs.productTable.setCurrentRow(supplierProductList.value[0])
+		}
+		supplierProductLoading.value = false
+	})
+}
+
+/**
+ * 产品多选带回保存
+ * 将弹出框选中的内容保存到工序表
+ */
+const handleProductSelected = (selection) => {
+	const dataList = []
+	selection.forEach((item) => {
+		const newProduct = {
+			id: null,
+			tenantId: currentSupplier.value.tenantId,
+			supplierId: currentSupplier.value.id,
+			supplierName: currentSupplier.value.name,
+			productId: item.id,
+			productCode: item.productCode,
+			productDescription: item.description
+		}
+		dataList.push(newProduct)
+	})
+	saveSupplierProduct(dataList).then((res) => {
+		if (res.code === 200) {
+			getCurrentSupplierProduct()
+		}
+	})
+}
+const handleCurrentProductChange = (row) => {
+	if (row) {
+		currentProduct.value = row
+		getCurrentSupplierProductProcess()
+	}
+}
+
+const handleDelProduct = (row) => {
+	proxy.$modal
+		.confirm('确认删除数据项?')
+		.then(() => {
+			removeSupplierProduct(row.id).then((res) => {
+				if (res.code === 200) {
+					proxy.$modal.msgSuccess('删除成功!')
+					getCurrentSupplierProduct()
+				}
+			})
+		})
+		.catch(() => {})
+}
+
+/**************************************** 工序相关 ****************************************/
+const getCurrentSupplierProductProcess = () => {
+	supplierProductProcessLoading.value = true
+	queryProductProcessParams.value.supplierId = currentSupplier.value.id
+	queryProductProcessParams.value.productId = currentProduct.value.productId
+	getSupplierProductProcess(queryProductProcessParams.value).then((res) => {
+		supplierProductProcessList.value = res.data
+		supplierProductProcessLoading.value = false
+	})
+}
+
+/** 工序打开对话框方法 */
+const handleShowProcessesDialog = (row) => {
+	proxy.$refs.processesRef.open(row)
+}
+
+/**
+ * 产品多选带回保存
+ * 将弹出框选中的内容保存到工序表
+ */
+const handleProcessSelected = (selection) => {
+	const dataList = []
+	selection.forEach((item) => {
+		const newProcess = {
+			id: null,
+			tenantId: currentSupplier.value.tenantId,
+			supplierId: currentSupplier.value.id,
+			supplierName: currentSupplier.value.name,
+			technologicalProcessId: currentProduct.value.technologicalProcessId,
+			technologicalVersion: currentProduct.value.technologicalVersion,
+			productId: currentProduct.value.productId,
+			productDescription: currentProduct.value.productDescription,
+			processId: item.processId,
+			processStepNumber: item.processStepNumber,
+			processCode: item.processCode,
+			processAlias: item.processAlias,
+			price: 0.0,
+			sttlementType: 1,
+			remark: ''
+		}
+		dataList.push(newProcess)
+	})
+	saveSupplierProductProcess(dataList).then((res) => {
+		if (res.code === 200) {
+			getCurrentSupplierProductProcess()
+		}
+	})
+}
+
+// 保存工序
+const handleSaveProcess = (row) => {
+	saveSupplierProductProcess(supplierProductProcessList.value).then((res) => {
+		if (res.code === 200) {
+			processEditStatus.value = false
+			getCurrentSupplierProductProcess()
+		}
+	})
+}
+
+// 删除工序
+const handleDelProcess = (row) => {
+	proxy.$modal
+		.confirm('确认删除数据项?')
+		.then(() => {
+			removeSupplierProductProcess(row.id).then((res) => {
+				if (res.code === 200) {
+					proxy.$modal.msgSuccess('删除成功!')
+					getCurrentSupplierProductProcess()
+				}
+			})
+		})
+		.catch(() => {})
+}
 
 onMounted(() => {
 	getList()