addDrawer.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <template>
  2. <!-- 新增对账详情抽屉 -->
  3. <el-drawer v-model="drawer.visible" size="75%" direction="rtl" :before-close="handleDrawerClose" :close-on-click-modal="true">
  4. <template #header>
  5. <div class="drawer-header">
  6. <span class="order-title">新增对账</span>
  7. </div>
  8. </template>
  9. <div class="drawer-content">
  10. <el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
  11. <!-- 基本信息 -->
  12. <el-divider content-position="left">
  13. <span style="color: #409eff; font-weight: 600">基本信息</span>
  14. </el-divider>
  15. <el-row :gutter="20">
  16. <el-col :span="8" v-if="isEdit">
  17. <el-form-item label="对账单号" prop="statementOrderNo">
  18. <el-input v-model="form.statementOrderNo" disabled />
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="8" v-if="isEdit">
  22. <el-form-item label="对账状态" prop="statementStatus">
  23. <el-input v-model="form.statementStatus" disabled />
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="客户名称" prop="customerId">
  28. <el-select
  29. v-model="form.customerId"
  30. filterable
  31. remote
  32. reserve-keyword
  33. placeholder="请输入客户名称"
  34. :remote-method="remoteSearchCustomer"
  35. :loading="customerLoading"
  36. clearable
  37. style="width: 100%"
  38. @change="handleCustomerChange"
  39. >
  40. <el-option v-for="item in customerOptions" :key="item.id" :label="item.customerName" :value="item.id" />
  41. </el-select>
  42. </el-form-item>
  43. </el-col>
  44. </el-row>
  45. <el-row :gutter="20">
  46. <el-col :span="8">
  47. <el-form-item label="对账单金额" prop="amount">
  48. <el-input v-model="form.amount" disabled />
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="8">
  52. <el-form-item label="对账人" prop="statementSelfId">
  53. <el-select
  54. v-model="form.statementSelfId"
  55. placeholder="请选择对账人"
  56. clearable
  57. filterable
  58. style="width: 100%"
  59. @change="handleStaffChange"
  60. >
  61. <el-option v-for="staff in staffOptions" :key="staff.staffId" :label="staff.staffName" :value="staff.staffId" />
  62. </el-select>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="8">
  66. <el-form-item label="对账人联系方式" prop="statementSelfPhone">
  67. <el-input v-model="form.statementSelfPhone" placeholder="请填写对账人联系方式" clearable />
  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="statementDate">
  74. <el-date-picker v-model="form.statementDate" type="date" placeholder="请选择对账日期" style="width: 100%" value-format="YYYY-MM-DD" />
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="8">
  78. <el-form-item label="支付状态" prop="isPaymentStatus">
  79. <el-select v-model="form.isPaymentStatus" placeholder="请选择支付状态" clearable style="width: 100%">
  80. <el-option v-for="dict in payment_status" :key="dict.value" :label="dict.label" :value="dict.value" />
  81. </el-select>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="8">
  85. <el-form-item label="发票状态" prop="isInvoiceStatus">
  86. <el-select v-model="form.isInvoiceStatus" placeholder="请选择发票状态" clearable style="width: 100%">
  87. <el-option v-for="dict in invoice_issuance_status" :key="dict.value" :label="dict.label" :value="dict.value" />
  88. </el-select>
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. <el-row :gutter="20">
  93. <el-col :span="24">
  94. <el-form-item label="备注" prop="remark">
  95. <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" maxlength="500" show-word-limit />
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. <!-- 对账明细 -->
  100. <el-divider content-position="left">
  101. <span style="color: #409eff; font-weight: 600">对账明细</span>
  102. </el-divider>
  103. <div class="table-actions" style="margin-bottom: 15px">
  104. <el-button type="primary" icon="Plus" @click="handleAddDetail">选择订单</el-button>
  105. </div>
  106. <el-table :data="form.detailList" border style="width: 100%; margin-bottom: 20px">
  107. <el-table-column type="index" label="序号" width="60" align="center" />
  108. <el-table-column prop="orderNo" label="订单编号" min-width="150" align="center" />
  109. <el-table-column prop="deliverCode" label="发货单编号" min-width="150" align="center" />
  110. <el-table-column prop="amount" label="金额" min-width="120" align="center" />
  111. <el-table-column prop="orderTime" label="下单日期" min-width="120" align="center" />
  112. <el-table-column prop="userName" label="下单人" min-width="100" align="center" />
  113. <el-table-column prop="userDept" label="部门" min-width="120" align="center" />
  114. </el-table>
  115. <!--
  116. <div v-if="form.detailList.length === 0" class="empty-data">
  117. <el-empty description="暂无数据" :image-size="100" />
  118. </div> -->
  119. <!-- 商品清单 -->
  120. <el-divider content-position="left">
  121. <span style="color: #409eff; font-weight: 600">商品清单</span>
  122. </el-divider>
  123. <el-table :data="pagedProductList" border style="width: 100%; margin-bottom: 20px">
  124. <el-table-column
  125. type="index"
  126. label="序号"
  127. width="60"
  128. align="center"
  129. :index="(index) => (productPage.pageNum - 1) * productPage.pageSize + index + 1"
  130. />
  131. <el-table-column prop="orderNo" label="订单编号" min-width="120" align="center" />
  132. <el-table-column prop="productNo" label="商品编号" min-width="120" align="center" />
  133. <el-table-column prop="itemName" label="商品名称" min-width="180" align="center" />
  134. <el-table-column prop="unitName" label="单位" width="80" align="center" />
  135. <el-table-column prop="quantity" label="数量" width="100" align="center" />
  136. <el-table-column prop="unitPrice" label="单价" width="100" align="center">
  137. <template #default="scope">
  138. {{ scope.row.unitPrice ? Number(scope.row.unitPrice).toFixed(2) : '0.00' }}
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="小计" width="120" align="center">
  142. <template #default="scope">
  143. {{ (Number(scope.row.quantity || 0) * Number(scope.row.unitPrice || 0)).toFixed(2) }}
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. <!-- 分页 -->
  148. <el-pagination
  149. v-if="form.productList.length > 0"
  150. v-model:current-page="productPage.pageNum"
  151. v-model:page-size="productPage.pageSize"
  152. :page-sizes="[10, 20, 50, 100]"
  153. layout="total, sizes, prev, pager, next, jumpers"
  154. :total="productPage.total"
  155. @size-change="handleProductSizeChange"
  156. @current-change="handleProductCurrentChange"
  157. style="margin-top: 15px"
  158. />
  159. <!-- 对账附件 -->
  160. <el-divider content-position="left">
  161. <span style="color: #409eff; font-weight: 600">对账附件</span>
  162. </el-divider>
  163. <el-upload
  164. :action="uploadAction"
  165. :on-success="handleUploadSuccess"
  166. :before-upload="beforeUpload"
  167. :show-file-list="false"
  168. multiple
  169. style="margin-bottom: 10px"
  170. >
  171. <el-button type="primary" icon="Upload">点击上传</el-button>
  172. </el-upload>
  173. <el-table :data="fileList" border style="width: 100%; margin-bottom: 20px">
  174. <el-table-column type="index" label="序号" width="80" align="center" />
  175. <el-table-column prop="name" label="文件名称" min-width="200" align="center" />
  176. <el-table-column prop="url" label="文件地址" min-width="250" align="center">
  177. <template #default="scope">
  178. {{ scope.row.url || '暂无地址' }}
  179. </template>
  180. </el-table-column>
  181. <el-table-column label="操作" width="250" align="center">
  182. <template #default="scope">
  183. <el-button type="primary" link @click="handleDownloadFile(scope.row)">下载</el-button>
  184. <el-button type="primary" link @click="handlePreviewFile(scope.row)">预览</el-button>
  185. <el-button type="danger" link @click="handleRemoveFile(scope.$index)">删除</el-button>
  186. </template>
  187. </el-table-column>
  188. </el-table>
  189. <!--
  190. <div v-if="fileList.length === 0" class="empty-data">
  191. <el-empty description="暂无附件" :image-size="100" />
  192. </div> -->
  193. </el-form>
  194. </div>
  195. <template #footer>
  196. <div class="drawer-footer">
  197. <el-button @click="handleDrawerClose(() => (drawer.visible = false))">取消</el-button>
  198. <el-button type="primary" :loading="buttonLoading" @click="handleSubmit">确定</el-button>
  199. </div>
  200. </template>
  201. </el-drawer>
  202. <!-- 客户订单抽屉 -->
  203. <OrderMainDrawer ref="orderMainDrawerRef" @success="handleOrderSelected" />
  204. </template>
  205. <script setup name="AddDrawer" lang="ts">
  206. import { addStatementOrder, updateStatementOrder } from '@/api/bill/statementOrder';
  207. import { StatementOrderForm } from '@/api/bill/statementOrder/types';
  208. import { StatementDetailForm } from '@/api/bill/statementDetail/types';
  209. import { getListBycustomerName } from '@/api/customer/customerFile/customerInfo';
  210. import { CustomerInfoVO } from '@/api/customer/customerFile/customerInfo/types';
  211. import { listOrderMain, getOrderMain } from '@/api/order/orderMain';
  212. import { OrderMainVO, OrderMainQuery, OrderMainForm } from '@/api/order/orderMain/types';
  213. import { OrderDeliverVO } from '@/api/order/orderDeliver/types';
  214. import { listComStaff } from '@/api/company/comStaff';
  215. import { ComStaffVO, ComStaffQuery } from '@/api/company/comStaff/types';
  216. import OrderMainDrawer from './orderMainDrawer.vue';
  217. import { getCustomerDeliverOrders } from '@/api/order/orderDeliver';
  218. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  219. const { statement_status, invoice_issuance_status, payment_status } = toRefs<any>(
  220. proxy?.useDict('statement_status', 'statement_order_type', 'invoice_issuance_status', 'payment_status')
  221. );
  222. const initFormData: StatementOrderForm = {
  223. id: undefined,
  224. statementOrderNo: undefined,
  225. customerId: undefined,
  226. customerNo: undefined,
  227. customerName: undefined,
  228. amount: undefined,
  229. statementSelfId: undefined,
  230. statementSelf: undefined,
  231. statementSelfPhone: undefined,
  232. statementStatus: undefined,
  233. isPaymentStatus: '1',
  234. isInvoiceStatus: '0',
  235. statementDate: undefined,
  236. annexAddress: undefined,
  237. rejectRemark: undefined,
  238. remark: undefined,
  239. detailList: [],
  240. productList: []
  241. };
  242. const emit = defineEmits(['success']);
  243. const formRef = ref<any>();
  244. const buttonLoading = ref(false);
  245. const form = ref<
  246. StatementOrderForm & {
  247. actualAmount?: string;
  248. accountingVerification?: string;
  249. skuProductName?: string;
  250. skuProductModel?: string;
  251. attachmentRemark?: string;
  252. }
  253. >({ ...initFormData });
  254. const rules = reactive({
  255. customerName: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
  256. statementSelfId: [{ required: true, message: '请选择对账人', trigger: 'blur' }],
  257. statementSelfPhone: [
  258. { required: true, message: '请输入对账人手机号', trigger: 'blur' },
  259. { pattern: /^1[3-9]\d{9}$/ as RegExp, message: '请输入正确的手机号格式', trigger: 'blur' }
  260. ]
  261. } as any);
  262. const fileList = ref<any[]>([]);
  263. const productPage = reactive({
  264. pageNum: 1,
  265. pageSize: 10,
  266. total: 0
  267. });
  268. const drawer = reactive<DialogOption>({
  269. visible: false,
  270. title: '新增对账'
  271. });
  272. const isEdit = ref(false); // 是否为编辑模式
  273. const customerLoading = ref(false);
  274. const customerOptions = ref<CustomerInfoVO[]>([]);
  275. const staffOptions = ref<ComStaffVO[]>([]);
  276. const orderMainDrawerRef = ref<any>();
  277. const uploadAction = import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload';
  278. const currentSelectedOrders = ref<OrderDeliverVO[]>([]);
  279. const preloadedOrders = ref<OrderDeliverVO[]>([]); // 预加载的订单列表
  280. /** 计算当前页的商品列表 */
  281. const pagedProductList = computed(() => {
  282. const start = (productPage.pageNum - 1) * productPage.pageSize;
  283. const end = start + productPage.pageSize;
  284. return form.value.productList?.slice(start, end) || [];
  285. });
  286. const preloadedTotal = ref(0); // 预加载的订单总数
  287. /** 打开新增/编辑对账详情抽屉 */
  288. const open = (id?: string | number, data?: StatementOrderForm) => {
  289. reset();
  290. if (id && data) {
  291. // 编辑模式
  292. isEdit.value = true;
  293. drawer.title = '编辑对账';
  294. Object.assign(form.value, data);
  295. // 将客户信息添加到下拉选项中,以便回显
  296. if (data.customerId && data.customerName) {
  297. customerOptions.value = [
  298. {
  299. id: data.customerId,
  300. customerName: data.customerName,
  301. customerNo: data.customerNo || ''
  302. } as CustomerInfoVO
  303. ];
  304. }
  305. // 解析附件地址并回显附件列表
  306. if (data.annexAddress) {
  307. const urls = data.annexAddress.split(',').filter((url) => url.trim());
  308. fileList.value = urls.map((url, index) => {
  309. const fileName = url.split('/').pop() || `附件${index + 1}`;
  310. return {
  311. name: fileName,
  312. url: url.trim(),
  313. id: undefined
  314. };
  315. });
  316. }
  317. // 设置商品列表分页总数
  318. if (data.productList && data.productList.length > 0) {
  319. productPage.total = data.productList.length;
  320. }
  321. } else {
  322. // 新增模式
  323. isEdit.value = false;
  324. drawer.title = '新增对账';
  325. }
  326. // 先打开抽屉
  327. drawer.visible = true;
  328. // 异步加载员工列表
  329. getStaffList();
  330. // 编辑模式下,如果有客户ID,异步预加载订单列表
  331. if (id && data?.customerId) {
  332. preloadOrders(data.customerId);
  333. }
  334. };
  335. /** 表单重置 */
  336. const reset = () => {
  337. form.value = { ...initFormData };
  338. fileList.value = [];
  339. productPage.pageNum = 1;
  340. productPage.pageSize = 10;
  341. productPage.total = 0;
  342. customerOptions.value = [];
  343. currentSelectedOrders.value = [];
  344. preloadedOrders.value = [];
  345. preloadedTotal.value = 0;
  346. formRef.value?.clearValidate();
  347. };
  348. /** 远程搜索客户 */
  349. const remoteSearchCustomer = async (query: string) => {
  350. if (query) {
  351. customerLoading.value = true;
  352. try {
  353. const res = await getListBycustomerName(query);
  354. customerOptions.value = res.data;
  355. } catch (error) {
  356. console.error(error);
  357. } finally {
  358. customerLoading.value = false;
  359. }
  360. } else {
  361. customerOptions.value = [];
  362. }
  363. };
  364. /** 客户变更 */
  365. const handleCustomerChange = async (customerId: string | number) => {
  366. if (customerId) {
  367. const customer = customerOptions.value.find((item) => item.id === customerId);
  368. if (customer) {
  369. form.value.customerName = customer.customerName;
  370. form.value.customerNo = customer.customerNo;
  371. }
  372. // 预加载订单列表
  373. await preloadOrders(customerId);
  374. } else {
  375. form.value.customerName = undefined;
  376. form.value.customerNo = undefined;
  377. preloadedOrders.value = [];
  378. preloadedTotal.value = 0;
  379. }
  380. };
  381. /** 预加载订单列表 */
  382. const preloadOrders = async (customerId: string | number) => {
  383. try {
  384. const res = await getCustomerDeliverOrders(customerId);
  385. preloadedOrders.value = res.rows || [];
  386. preloadedTotal.value = res.total || 0;
  387. } catch (error) {
  388. console.error('预加载订单列表失败:', error);
  389. preloadedOrders.value = [];
  390. preloadedTotal.value = 0;
  391. }
  392. };
  393. /** 选择订单 */
  394. const handleSelectOrder = () => {
  395. if (!form.value.customerId) {
  396. proxy?.$modal.msgWarning('请先选择客户');
  397. return;
  398. }
  399. // 传递当前已选中的订单、产品列表、预加载的订单列表和总数
  400. orderMainDrawerRef.value?.open(
  401. form.value.customerId,
  402. currentSelectedOrders.value,
  403. form.value.productList,
  404. preloadedOrders.value,
  405. preloadedTotal.value
  406. );
  407. };
  408. /** 获取员工列表 */
  409. const getStaffList = async () => {
  410. try {
  411. const res = await listComStaff();
  412. staffOptions.value = res.rows || [];
  413. } catch (error) {
  414. console.error('获取员工列表失败:', error);
  415. }
  416. };
  417. /** 员工变更 */
  418. const handleStaffChange = (staffId: string | number) => {
  419. if (staffId) {
  420. const staff = staffOptions.value.find((item) => item.staffId === staffId);
  421. if (staff) {
  422. form.value.statementSelf = staff.staffName || '';
  423. form.value.statementSelfPhone = staff.phone || '';
  424. }
  425. } else {
  426. form.value.statementSelf = undefined;
  427. form.value.statementSelfPhone = '';
  428. }
  429. };
  430. /** 订单选择成功回调 */
  431. const handleOrderSelected = (data: any) => {
  432. const { orders, products } = data;
  433. if (orders && orders.length > 0) {
  434. let totalAmount = 0;
  435. // 保存当前选中的订单
  436. currentSelectedOrders.value = orders;
  437. // 清空现有数据
  438. form.value.detailList = [];
  439. form.value.productList = [];
  440. // 填充对账明细
  441. orders.forEach((order: any) => {
  442. totalAmount += Number(order.totalAmount || 0);
  443. const detail: any = {
  444. id: undefined,
  445. statementOrderId: undefined,
  446. orderNo: order.orderCode,
  447. deliverCode: order.deliverCode || '',
  448. orderTime: order.orderTime || '',
  449. amount: order.totalAmount,
  450. type: order.orderType || '',
  451. orderId: order.id,
  452. signingDate: order.receivingTime || order.signingDate || '',
  453. userId: order.createBy,
  454. userName: order.createName || '',
  455. userDeptId: order.createDept,
  456. userDept: order.createDeptName || ''
  457. };
  458. form.value.detailList?.push(detail);
  459. });
  460. // 设置总金额
  461. form.value.amount = totalAmount;
  462. // 直接使用传递过来的产品列表
  463. if (products && products.length > 0) {
  464. form.value.productList = products;
  465. productPage.total = products.length;
  466. }
  467. }
  468. };
  469. /** 添加对账明细 */
  470. const handleAddDetail = () => {
  471. if (!form.value.customerId) {
  472. proxy?.$modal.msgWarning('请先选择客户');
  473. return;
  474. }
  475. // 传递当前已选中的订单、产品列表、预加载的订单列表和总数
  476. orderMainDrawerRef.value?.open(
  477. form.value.customerId,
  478. currentSelectedOrders.value,
  479. form.value.productList,
  480. preloadedOrders.value,
  481. preloadedTotal.value
  482. );
  483. };
  484. /** 产品分页大小改变 */
  485. const handleProductSizeChange = (val: number) => {
  486. productPage.pageSize = val;
  487. };
  488. /** 产品分页页码改变 */
  489. const handleProductCurrentChange = (val: number) => {
  490. productPage.pageNum = val;
  491. };
  492. /** 上传前校验 */
  493. const beforeUpload = (file: any) => {
  494. const isLt50M = file.size / 1024 / 1024 < 50;
  495. if (!isLt50M) {
  496. proxy?.$modal.msgWarning('上传文件大小不能超过 50MB!');
  497. }
  498. return isLt50M;
  499. };
  500. /** 上传成功回调 */
  501. const handleUploadSuccess = (response: any, file: any) => {
  502. if (response.code === 200) {
  503. fileList.value.push({
  504. name: file.name,
  505. url: response.data.url,
  506. id: undefined
  507. });
  508. // 更新表单中的附件地址
  509. form.value.annexAddress = fileList.value
  510. .map((f) => f.url)
  511. .filter(Boolean)
  512. .join(',');
  513. proxy?.$modal.msgSuccess('上传成功');
  514. } else {
  515. proxy?.$modal.msgError(response.msg || '上传失败');
  516. }
  517. };
  518. /** 删除文件 */
  519. const handleRemoveFile = (index: number) => {
  520. fileList.value.splice(index, 1);
  521. // 更新表单中的附件地址
  522. form.value.annexAddress = fileList.value
  523. .map((f) => f.url)
  524. .filter(Boolean)
  525. .join(',');
  526. };
  527. /** 下载文件 */
  528. const handleDownloadFile = async (file: any) => {
  529. if (!file.url) {
  530. proxy?.$modal.msgWarning('文件地址不存在');
  531. return;
  532. }
  533. try {
  534. // 使用fetch获取文件
  535. const response = await fetch(file.url);
  536. const blob = await response.blob();
  537. // 创建Blob URL
  538. const blobUrl = window.URL.createObjectURL(blob);
  539. // 创建下载链接
  540. const link = document.createElement('a');
  541. link.href = blobUrl;
  542. link.download = file.name || '附件';
  543. document.body.appendChild(link);
  544. link.click();
  545. // 清理
  546. document.body.removeChild(link);
  547. window.URL.revokeObjectURL(blobUrl);
  548. } catch (error) {
  549. console.error('下载失败:', error);
  550. // 如果fetch失败,回退到直接打开链接的方式
  551. const link = document.createElement('a');
  552. link.href = file.url;
  553. link.download = file.name || '附件';
  554. link.target = '_blank';
  555. document.body.appendChild(link);
  556. link.click();
  557. document.body.removeChild(link);
  558. }
  559. };
  560. /** 预览文件 */
  561. const handlePreviewFile = (file: any) => {
  562. if (!file.url) {
  563. proxy?.$modal.msgWarning('文件地址不存在');
  564. return;
  565. }
  566. // 在新窗口打开文件
  567. window.open(file.url, '_blank');
  568. };
  569. /** 提交表单 */
  570. const handleSubmit = async () => {
  571. if (!formRef.value) return;
  572. console.log(form.value);
  573. await formRef.value.validate(async (valid) => {
  574. if (valid) {
  575. buttonLoading.value = true;
  576. try {
  577. if (isEdit.value) {
  578. // 编辑模式
  579. await updateStatementOrder(form.value);
  580. proxy?.$modal.msgSuccess('修改成功');
  581. } else {
  582. // 新增模式
  583. await addStatementOrder(form.value);
  584. proxy?.$modal.msgSuccess('新增成功');
  585. }
  586. drawer.visible = false;
  587. emit('success');
  588. } catch (error) {
  589. console.error(error);
  590. } finally {
  591. buttonLoading.value = false;
  592. }
  593. }
  594. });
  595. };
  596. /** 关闭抽屉前的回调 */
  597. const handleDrawerClose = (done: () => void) => {
  598. if (buttonLoading.value) {
  599. return;
  600. }
  601. done();
  602. reset();
  603. };
  604. defineExpose({
  605. open
  606. });
  607. </script>
  608. <style scoped lang="scss">
  609. .drawer-header {
  610. display: flex;
  611. align-items: center;
  612. gap: 10px;
  613. .order-title {
  614. font-size: 16px;
  615. font-weight: 600;
  616. color: #303133;
  617. }
  618. }
  619. .drawer-content {
  620. padding: 0 20px 20px;
  621. height: calc(100% - 60px);
  622. overflow-y: auto;
  623. }
  624. .assign-dialog-content {
  625. padding: 0 10px;
  626. }
  627. .assign-target-section {
  628. margin-bottom: 20px;
  629. .target-input-wrapper {
  630. display: flex;
  631. align-items: center;
  632. gap: 8px;
  633. .required-mark {
  634. color: #f56c6c;
  635. font-size: 14px;
  636. }
  637. .label {
  638. font-size: 14px;
  639. color: #606266;
  640. white-space: nowrap;
  641. }
  642. }
  643. .or-divider {
  644. display: flex;
  645. align-items: center;
  646. justify-content: center;
  647. font-size: 14px;
  648. color: #909399;
  649. }
  650. }
  651. .product-list-section {
  652. margin-top: 20px;
  653. }
  654. .detail-header {
  655. padding: 15px 20px;
  656. background-color: #f5f7fa;
  657. border-radius: 4px;
  658. margin-bottom: 20px;
  659. .info-item {
  660. display: flex;
  661. flex-direction: column;
  662. gap: 5px;
  663. .label {
  664. font-size: 12px;
  665. color: #909399;
  666. }
  667. .value {
  668. font-size: 14px;
  669. color: #303133;
  670. font-weight: 500;
  671. }
  672. }
  673. }
  674. .detail-tabs {
  675. .tab-actions {
  676. margin-bottom: 15px;
  677. }
  678. }
  679. :deep(.el-alert__title) {
  680. font-size: 13px;
  681. }
  682. .empty-data {
  683. padding: 20px 0;
  684. text-align: center;
  685. }
  686. .drawer-footer {
  687. display: flex;
  688. justify-content: flex-end;
  689. gap: 10px;
  690. padding: 15px 20px;
  691. border-top: 1px solid #e4e7ed;
  692. }
  693. :deep(.el-upload__tip) {
  694. margin-top: 8px;
  695. font-size: 12px;
  696. color: #909399;
  697. }
  698. </style>