You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

538 lines
22 KiB

4 weeks ago
1 month ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
1 month ago
4 weeks ago
4 weeks ago
4 weeks ago
1 month ago
1 month ago
4 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
4 weeks ago
2 months ago
  1. <template>
  2. <div class="customer-css">
  3. <el-form :inline="true" label-position="top" :model="searchData">
  4. <el-form-item label="产品编码">
  5. <el-input v-model="searchData.partNo" clearable style="width: 150px"></el-input>
  6. </el-form-item>
  7. <el-form-item label="物料名称">
  8. <el-input v-model="searchData.partDesc" clearable style="width: 150px"></el-input>
  9. </el-form-item>
  10. <el-form-item label="状态">
  11. <el-input v-model="searchData.remark1" clearable style="width: 120px"></el-input>
  12. </el-form-item>
  13. <el-form-item label=" ">
  14. <el-button type="primary" @click="searchTable()">查询</el-button>
  15. <!-- <el-button type="primary" @click="addModal()" v-if="shouldShowButton">新增</el-button> -->
  16. </el-form-item>
  17. </el-form>
  18. <el-table
  19. :data="dataList"
  20. :height="searchData.height"
  21. border
  22. v-loading="dataListLoading"
  23. style="width: 100%;">
  24. <el-table-column
  25. v-for="(item, index) in columnList"
  26. :key="index"
  27. :sortable="item.columnSortable"
  28. :prop="item.columnProp"
  29. :header-align="item.headerAlign"
  30. :show-overflow-tooltip="item.showOverflowTooltip"
  31. :align="item.align"
  32. :fixed="item.fixed == '' ? false : item.fixed"
  33. :min-width="item.columnWidth"
  34. :label="item.columnLabel">
  35. <template slot-scope="scope">
  36. <span v-if="!item.columnHidden">{{ formatColumn(scope.row, item) }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column
  40. fixed="right"
  41. header-align="center"
  42. align="center"
  43. width="100"
  44. label="操作">
  45. <template slot-scope="scope">
  46. <el-link style="cursor: pointer" @click="openPriceSheet(scope.row)">价格表查询</el-link>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <!-- 新增/编辑弹窗 -->
  51. <el-dialog :title="dialogTitle" :close-on-click-modal="false" v-drag :visible.sync="dialogVisible" width="900px">
  52. <div class="dialog-content">
  53. <el-form label-position="top" :model="formData" :rules="formRules" ref="formRef">
  54. <el-row :gutter="20">
  55. <el-col :span="8">
  56. <el-form-item label="产品编码" prop="partNo">
  57. <el-input v-model="formData.partNo" placeholder="请输入产品编码"></el-input>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="8">
  61. <el-form-item label="物料名称" prop="partDesc">
  62. <el-input v-model="formData.partDesc" placeholder="请输入物料名称"></el-input>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="8">
  66. <el-form-item label="计量单位" prop="umid">
  67. <el-input v-model="formData.umid" placeholder="请输入计量单位"></el-input>
  68. </el-form-item>
  69. </el-col>
  70. </el-row>
  71. <el-row :gutter="20">
  72. <el-col :span="8">
  73. <el-form-item label="询价数量" prop="qty">
  74. <el-input v-model="formData.qty" type="number" placeholder="请输入询价数量"></el-input>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="8">
  78. <el-form-item label="状态" prop="remark1">
  79. <el-select v-model="formData.remark1" placeholder="请选择状态" clearable style="width: 100%">
  80. <el-option label="询价中" value="询价中"></el-option>
  81. <el-option label="报价中" value="报价中"></el-option>
  82. <el-option label="已完成" value="已完成"></el-option>
  83. <el-option label="已取消" value="已取消"></el-option>
  84. </el-select>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-form-item label="材料费用" prop="materialCost">
  89. <el-input v-model="formData.materialCost" type="number" placeholder="请输入材料费用"></el-input>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row :gutter="20">
  94. <el-col :span="8">
  95. <el-form-item label="加工费" prop="produceFee">
  96. <el-input v-model="formData.produceFee" type="number" placeholder="请输入加工费"></el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="8">
  100. <el-form-item label="表面处理费" prop="surfaceFee">
  101. <el-input v-model="formData.surfaceFee" type="number" placeholder="请输入表面处理费"></el-input>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="8">
  105. <el-form-item label="利润" prop="profit">
  106. <el-input v-model="formData.profit" type="number" placeholder="请输入利润"></el-input>
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. <el-row :gutter="20">
  111. <el-col :span="8">
  112. <el-form-item label="未税单价" prop="price">
  113. <el-input v-model="formData.price" type="number" placeholder="请输入未税单价"></el-input>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="8">
  117. <el-form-item label="税率(%)" prop="taxRate">
  118. <el-input v-model="formData.taxRate" type="number" placeholder="请输入税率"></el-input>
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="8">
  122. <el-form-item label="含税单价" prop="tax">
  123. <el-input v-model="formData.tax" type="number" placeholder="请输入含税单价"></el-input>
  124. </el-form-item>
  125. </el-col>
  126. </el-row>
  127. <el-row :gutter="20">
  128. <el-col :span="8">
  129. <el-form-item label="关税" prop="duty">
  130. <el-input v-model="formData.duty" type="number" placeholder="请输入关税"></el-input>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="8">
  134. <el-form-item label="采购周期(天)" prop="purchaseCycle">
  135. <el-input v-model="formData.purchaseCycle" type="number" placeholder="请输入采购周期"></el-input>
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="8">
  139. <el-form-item label="模具费" prop="mouldFee">
  140. <el-input v-model="formData.mouldFee" type="number" placeholder="请输入模具费"></el-input>
  141. </el-form-item>
  142. </el-col>
  143. </el-row>
  144. <el-row :gutter="20">
  145. <el-col :span="8">
  146. <el-form-item label="附加费用" prop="additionalCost">
  147. <el-input v-model="formData.additionalCost" type="number" placeholder="请输入附加费用"></el-input>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="8">
  151. <el-form-item label="运费" prop="freight">
  152. <el-input v-model="formData.freight" type="number" placeholder="请输入运费"></el-input>
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="8">
  156. <el-form-item label="报价日期" prop="createdDate">
  157. <el-date-picker v-model="formData.createdDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%"></el-date-picker>
  158. </el-form-item>
  159. </el-col>
  160. </el-row>
  161. <el-row :gutter="20">
  162. <el-col :span="24">
  163. <el-form-item label="备注" prop="remark">
  164. <el-input type="textarea" :rows="3" v-model="formData.remark" placeholder="请输入备注"></el-input>
  165. </el-form-item>
  166. </el-col>
  167. </el-row>
  168. </el-form>
  169. </div>
  170. <div slot="footer" class="dialog-footer" style="margin-top: 20px">
  171. <el-button type="primary" @click="submitData()">保存</el-button>
  172. <el-button @click="dialogVisible = false">取消</el-button>
  173. </div>
  174. </el-dialog>
  175. <el-dialog
  176. title="价格表查询"
  177. :visible.sync="priceSheetDialogVisible"
  178. width="700px"
  179. :close-on-click-modal="false"
  180. v-drag
  181. append-to-body
  182. >
  183. <el-form :inline="true" label-position="top" class="price-sheet-header-form">
  184. <el-form-item label="产品编码">
  185. <el-input :value="displayText(priceSheetHeader.partNo)" disabled style="width: 140px" />
  186. </el-form-item>
  187. <el-form-item label="物料名称">
  188. <el-input :value="displayText(priceSheetHeader.partDesc)" disabled style="width: 180px" />
  189. </el-form-item>
  190. <el-form-item label="价格日期">
  191. <el-input :value="displayText(formatDateOnly(priceSheetHeader.priceDate))" disabled style="width: 120px" />
  192. </el-form-item>
  193. <el-form-item label="供应商编码">
  194. <el-input :value="displayText(priceSheetHeader.supplierId)" disabled style="width: 120px" />
  195. </el-form-item>
  196. <el-form-item label="供应商名称">
  197. <el-input :value="displayText(priceSheetHeader.supplierName)" disabled style="width: 160px" />
  198. </el-form-item>
  199. <el-form-item label="币种">
  200. <el-input :value="displayText(priceSheetHeader.currency)" disabled style="width: 70px" />
  201. </el-form-item>
  202. </el-form>
  203. <el-table
  204. :data="priceSheetDetailList"
  205. :height="320"
  206. border
  207. stripe
  208. v-loading="priceSheetLoading"
  209. style="width: 100%"
  210. >
  211. <el-table-column prop="qtyStart" label="开始数量" min-width="110" header-align="center" align="right">
  212. <template slot-scope="scope">
  213. {{ formatNumber(scope.row.qtyStart) }}
  214. </template>
  215. </el-table-column>
  216. <el-table-column prop="qtyEnd" label="结束数量" min-width="110" header-align="center" align="right">
  217. <template slot-scope="scope">
  218. {{ formatNumber(scope.row.qtyEnd) }}
  219. </template>
  220. </el-table-column>
  221. <el-table-column prop="unitPrice" label="价格" min-width="120" header-align="center" align="right">
  222. <template slot-scope="scope">
  223. {{ formatNumber(scope.row.unitPrice) }}
  224. </template>
  225. </el-table-column>
  226. <el-table-column prop="remark" label="备注" min-width="200" header-align="center" align="left" show-overflow-tooltip />
  227. </el-table>
  228. <div slot="footer" class="dialog-footer">
  229. <el-button type="primary" @click="priceSheetDialogVisible = false">关闭</el-button>
  230. </div>
  231. </el-dialog>
  232. </div>
  233. </template>
  234. <script>
  235. // 请根据实际API路径调整导入
  236. import {
  237. getPurReplyPriceSheet,
  238. searchPurReplyHistList
  239. } from '@/api/supplier/purReplyHist.js'
  240. import { formatPartColumn } from '@/utils/purQuotationPartDisplay.js'
  241. export default {
  242. name: 'QuotationRecord',
  243. data() {
  244. return {
  245. dataList: [],
  246. dataListLoading: false,
  247. searchData: {
  248. partNo: '',
  249. partDesc: '',
  250. remark1: '',
  251. height: '200',
  252. page: 1,
  253. limit: 1000
  254. },
  255. type: 'add', // 假设类型
  256. dialogVisible: false,
  257. dialogTitle: '新增报价记录',
  258. formData: {
  259. id: '',
  260. partNo: '',
  261. partDesc: '',
  262. umid: '',
  263. qty: '',
  264. remark1: '',
  265. materialCost: '',
  266. produceFee: '',
  267. surfaceFee: '',
  268. profit: '',
  269. price: '',
  270. taxRate: '',
  271. tax: '',
  272. duty: '',
  273. purchaseCycle: '',
  274. mouldFee: '',
  275. additionalCost: '',
  276. freight: '',
  277. createdDate: '',
  278. remark: '',
  279. createdBy: ''
  280. },
  281. formRules: {
  282. partNo: [{ required: true, message: '请输入产品编码', trigger: 'blur' }]
  283. },
  284. priceSheetDialogVisible: false,
  285. priceSheetLoading: false,
  286. priceSheetHeader: {
  287. quotationReplyHistId: null,
  288. partNo: '',
  289. partDesc: '',
  290. priceDate: '',
  291. supplierId: '',
  292. supplierName: '',
  293. currency: ''
  294. },
  295. priceSheetDetailList: [],
  296. columnList: [
  297. { columnProp: 'partNo', headerAlign: 'center', align: 'left', columnLabel: '产品编码', columnWidth: 120, fixed: '', columnHidden: false, columnSortable: false },
  298. { columnProp: 'partDesc', headerAlign: 'center', align: 'left', columnLabel: '物料名称', columnWidth: 150, fixed: '', columnHidden: false, columnSortable: false },
  299. { columnProp: 'partNoOri', headerAlign: 'center', align: 'left', columnLabel: '临时编码', columnWidth: 120, fixed: '', columnHidden: false, columnSortable: false },
  300. { columnProp: 'partDescOri', headerAlign: 'center', align: 'left', columnLabel: '临时名称', columnWidth: 150, fixed: '', columnHidden: false, columnSortable: false },
  301. { columnProp: 'umid', headerAlign: 'center', align: 'center', columnLabel: '计量单位', columnWidth: 90, fixed: '', columnHidden: false, columnSortable: false },
  302. { columnProp: 'qty', headerAlign: 'center', align: 'right', columnLabel: '询价数量', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  303. // { columnProp: 'remark1', headerAlign: 'center', align: 'center', columnLabel: '状态', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  304. { columnProp: 'materialCost', headerAlign: 'center', align: 'right', columnLabel: '材料费用', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  305. { columnProp: 'produceFee', headerAlign: 'center', align: 'right', columnLabel: '加工费', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  306. { columnProp: 'surfaceFee', headerAlign: 'center', align: 'right', columnLabel: '表面处理费', columnWidth: 110, fixed: '', columnHidden: false, columnSortable: false },
  307. { columnProp: 'profit', headerAlign: 'center', align: 'right', columnLabel: '利润', columnWidth: 90, fixed: '', columnHidden: false, columnSortable: false },
  308. { columnProp: 'price', headerAlign: 'center', align: 'right', columnLabel: '未税单价', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  309. { columnProp: 'taxRate', headerAlign: 'center', align: 'right', columnLabel: '税率', columnWidth: 80, fixed: '', columnHidden: false, columnSortable: false },
  310. { columnProp: 'tax', headerAlign: 'center', align: 'right', columnLabel: '含税单价', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  311. { columnProp: 'duty', headerAlign: 'center', align: 'right', columnLabel: '关税', columnWidth: 90, fixed: '', columnHidden: false, columnSortable: false },
  312. { columnProp: 'purchaseCycle', headerAlign: 'center', align: 'center', columnLabel: '采购周期', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  313. { columnProp: 'mouldFee', headerAlign: 'center', align: 'right', columnLabel: '模具费', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  314. { columnProp: 'additionalCost', headerAlign: 'center', align: 'right', columnLabel: '附加费用', columnWidth: 100, fixed: '', columnHidden: false, columnSortable: false },
  315. { columnProp: 'freight', headerAlign: 'center', align: 'right', columnLabel: '运费', columnWidth: 90, fixed: '', columnHidden: false, columnSortable: false },
  316. { columnProp: 'createdDate', headerAlign: 'center', align: 'center', columnLabel: '报价日期', columnWidth: 120, fixed: '', columnHidden: false, columnSortable: true },
  317. { columnProp: 'remark', headerAlign: 'center', align: 'left', columnLabel: '备注', columnWidth: 180, fixed: '', columnHidden: false, columnSortable: false },
  318. { columnProp: 'createdBy', headerAlign: 'center', align: 'center', columnLabel: '最近更改人', columnWidth: 120, fixed: '', columnHidden: false, columnSortable: false }
  319. ]
  320. }
  321. },
  322. computed: {
  323. shouldShowButton() {
  324. // 根据类型返回布尔值
  325. return this.type === 'add';
  326. }
  327. },
  328. methods: {
  329. formatColumn(row, item) {
  330. return formatPartColumn(row, item.columnProp)
  331. },
  332. displayText(value) {
  333. if (value === null || value === undefined || value === '') {
  334. return '-'
  335. }
  336. return value
  337. },
  338. formatDateOnly(value) {
  339. if (!value) return ''
  340. if (typeof value === 'string') {
  341. return value.length >= 10 ? value.slice(0, 10) : value
  342. }
  343. const date = new Date(value)
  344. if (Number.isNaN(date.getTime())) {
  345. return ''
  346. }
  347. const pad = num => String(num).padStart(2, '0')
  348. return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
  349. },
  350. formatNumber(value) {
  351. if (value === null || value === undefined || value === '') {
  352. return '0'
  353. }
  354. const num = Number(value)
  355. if (Number.isNaN(num)) {
  356. return '0'
  357. }
  358. return String(Object.is(num, -0) ? 0 : num)
  359. },
  360. openPriceSheet(row) {
  361. if (!row || !row.id) {
  362. this.$message.warning('当前报价记录缺少主键,无法查询价格表')
  363. return
  364. }
  365. const params = {
  366. site: this.$store.state.user.site,
  367. quotationReplyHistId: row.id
  368. }
  369. this.priceSheetDialogVisible = true
  370. this.priceSheetLoading = true
  371. this.priceSheetHeader = {
  372. quotationReplyHistId: row.id,
  373. partNo: row.partNo || '',
  374. partDesc: row.partDesc || '',
  375. priceDate: row.createdDate || '',
  376. supplierId: '',
  377. supplierName: '',
  378. currency: ''
  379. }
  380. this.priceSheetDetailList = []
  381. getPurReplyPriceSheet(params).then(({ data }) => {
  382. if (data && data.code === 0 && data.row) {
  383. const responseRow = data.row
  384. this.priceSheetHeader = {
  385. quotationReplyHistId: responseRow.quotationReplyHistId || row.id,
  386. partNo: responseRow.partNo || row.partNo || '',
  387. partDesc: responseRow.partDesc || row.partDesc || '',
  388. priceDate: responseRow.priceDate || row.createdDate || '',
  389. supplierId: responseRow.supplierId || '',
  390. supplierName: responseRow.supplierName || '',
  391. currency: responseRow.currency || ''
  392. }
  393. this.priceSheetDetailList = responseRow.tierPriceList || []
  394. } else {
  395. this.priceSheetDetailList = []
  396. this.$message.error((data && data.msg) || '获取价格表失败')
  397. }
  398. this.priceSheetLoading = false
  399. }).catch(() => {
  400. this.priceSheetLoading = false
  401. this.priceSheetDetailList = []
  402. this.$message.error('获取价格表失败')
  403. })
  404. },
  405. // 初始化方法,供父组件调用
  406. init(inData) {
  407. if (inData) {
  408. this.searchData = { ...this.searchData, ...inData }
  409. }
  410. this.searchTable()
  411. },
  412. // 查询列表
  413. searchTable() {
  414. this.dataListLoading = true
  415. // TODO: 请替换为实际接口调用
  416. searchPurReplyHistList(this.searchData).then(({ data }) => {
  417. if (data && data.code === 0) {
  418. this.dataList = data.rows
  419. } else {
  420. this.dataList = []
  421. }
  422. this.dataListLoading = false
  423. })
  424. },
  425. // 新增
  426. addModal() {
  427. this.dialogTitle = '新增报价记录'
  428. this.formData = {
  429. id: '',
  430. partNo: '',
  431. partDesc: '',
  432. umid: '',
  433. qty: '',
  434. remark1: '',
  435. materialCost: '',
  436. produceFee: '',
  437. surfaceFee: '',
  438. profit: '',
  439. price: '',
  440. taxRate: '',
  441. tax: '',
  442. duty: '',
  443. purchaseCycle: '',
  444. mouldFee: '',
  445. additionalCost: '',
  446. freight: '',
  447. createdDate: '',
  448. remark: '',
  449. createdBy: (this.$store && this.$store.state && this.$store.state.user && this.$store.state.user.name) || ''
  450. }
  451. this.dialogVisible = true
  452. this.$nextTick(() => {
  453. if (this.$refs.formRef) {
  454. this.$refs.formRef.clearValidate()
  455. }
  456. })
  457. },
  458. // 编辑
  459. editModel(row) {
  460. this.dialogTitle = '编辑报价记录'
  461. this.formData = JSON.parse(JSON.stringify(row))
  462. this.dialogVisible = true
  463. this.$nextTick(() => {
  464. if (this.$refs.formRef) {
  465. this.$refs.formRef.clearValidate()
  466. }
  467. })
  468. },
  469. // 提交保存
  470. submitData() {
  471. this.$refs.formRef.validate((valid) => {
  472. if (!valid) return
  473. // TODO: 请替换为实际接口调用
  474. // const api = this.formData.id ? updateQuotation : createQuotation
  475. // api(this.formData).then(({ data }) => {
  476. // if (data && data.code === 0) {
  477. // this.$message.success(data.msg)
  478. // this.dialogVisible = false
  479. // this.searchTable()
  480. // } else {
  481. // this.$message.warning(data.msg)
  482. // }
  483. // })
  484. // 模拟保存,实际使用时请删除
  485. this.$message.success('保存成功')
  486. this.dialogVisible = false
  487. this.searchTable()
  488. })
  489. },
  490. // 删除
  491. deleteData(row) {
  492. this.$confirm('确认删除该条报价记录吗?', '提示', {
  493. confirmButtonText: '确认',
  494. cancelButtonText: '取消',
  495. type: 'warning'
  496. }).then(() => {
  497. // TODO: 请替换为实际接口调用
  498. // deleteQuotation(row.id).then(({ data }) => {
  499. // if (data.code === 0) {
  500. // this.$message.success('删除成功')
  501. // this.searchTable()
  502. // }
  503. // })
  504. // 模拟删除,实际使用时请删除
  505. this.$message.success('删除成功')
  506. this.searchTable()
  507. }).catch(() => {})
  508. }
  509. }
  510. }
  511. </script>
  512. <style scoped lang="scss">
  513. .dialog-content {
  514. width: 100%;
  515. max-height: 60vh;
  516. overflow-y: auto;
  517. padding-right: 10px;
  518. }
  519. .customer-css {
  520. padding: 10px;
  521. }
  522. .price-sheet-header-form {
  523. margin-bottom: 8px;
  524. }
  525. </style>