Commit adfd7a78f64b653b2e23b38062ee79796e4adc61

Authored by 曾国涛
1 parent ad33ec47

feat: 开票功能开发

src/pages/Invoice/components/InvoiceDetailTable.tsx
@@ -138,6 +138,11 @@ export default ({ recordId, details, updateDetails, readOnly }) => { @@ -138,6 +138,11 @@ export default ({ recordId, details, updateDetails, readOnly }) => {
138 //修改recordList中tid为record.tid的元素,将它的specification属性设置为invoiceProject的specification属性 138 //修改recordList中tid为record.tid的元素,将它的specification属性设置为invoiceProject的specification属性
139 const records = recordList.map((item) => { 139 const records = recordList.map((item) => {
140 if (item.tid === record.tid) { 140 if (item.tid === record.tid) {
  141 + item.projectName =
  142 + '*' +
  143 + invoiceProject.productAndServiceCatagoryAbbreviation +
  144 + '*' +
  145 + invoiceProject?.name;
141 item.specification = invoiceProject?.specification; 146 item.specification = invoiceProject?.specification;
142 item.unit = invoiceProject?.unit; 147 item.unit = invoiceProject?.unit;
143 item.taxRate = invoiceProject?.taxRate * 100; 148 item.taxRate = invoiceProject?.taxRate * 100;
src/pages/Invoice/components/InvoiceProjectSelect.tsx
@@ -24,7 +24,11 @@ export const InvoiceProjectSelect = ({ @@ -24,7 +24,11 @@ export const InvoiceProjectSelect = ({
24 setOptions( 24 setOptions(
25 data.map((item) => { 25 data.map((item) => {
26 return { 26 return {
27 - label: item.name, 27 + label:
  28 + '*' +
  29 + item.productAndServiceCatagoryAbbreviation +
  30 + '*' +
  31 + item?.name,
28 value: item.id, 32 value: item.id,
29 ...item, 33 ...item,
30 }; 34 };
@@ -42,6 +46,7 @@ export const InvoiceProjectSelect = ({ @@ -42,6 +46,7 @@ export const InvoiceProjectSelect = ({
42 /*readonly={readonly}*/ 46 /*readonly={readonly}*/
43 showSearch 47 showSearch
44 placeholder="请选择开票项目" 48 placeholder="请选择开票项目"
  49 + filterOption={(input, option) => (option?.label ?? '').includes(input)}
45 onChange={(e) => { 50 onChange={(e) => {
46 setInvoiceProject(options.find((item) => item.value === e)); 51 setInvoiceProject(options.find((item) => item.value === e));
47 onChange(e); 52 onChange(e);
src/pages/Order/components/InvoicingDrawerForm.tsx
1 // import { PlusOutlined } from '@ant-design/icons'; 1 // import { PlusOutlined } from '@ant-design/icons';
2 -import { InvoiceProjectSelect } from '@/pages/Invoice/components/InvoiceProjectSelect';  
3 import { 2 import {
4 postServiceConstInvoiceType, 3 postServiceConstInvoiceType,
5 postServiceConstInvoicingType, 4 postServiceConstInvoicingType,
  5 + postServiceConstListInvoiceDetailNames,
6 postServiceInvoiceApplyInvoice, 6 postServiceInvoiceApplyInvoice,
7 } from '@/services'; 7 } from '@/services';
8 import { enumToSelect } from '@/utils'; 8 import { enumToSelect } from '@/utils';
9 import { 9 import {
10 DrawerForm, 10 DrawerForm,
  11 + ProCard,
  12 + ProFormDigit,
11 ProFormGroup, 13 ProFormGroup,
12 ProFormList, 14 ProFormList,
13 ProFormMoney, 15 ProFormMoney,
@@ -168,6 +170,16 @@ export default ({ dataList, mainOrder, setVisible, onClose }) => { @@ -168,6 +170,16 @@ export default ({ dataList, mainOrder, setVisible, onClose }) => {
168 <ProFormList 170 <ProFormList
169 name="invoiceDetails" 171 name="invoiceDetails"
170 label="开票明细" 172 label="开票明细"
  173 + initialValue={dataList.map((item) => {
  174 + return {
  175 + projectName: item.productName,
  176 + specification: item.parameters,
  177 + unit: item.unit,
  178 + quantity: item.quantity,
  179 + price: item.productPrice,
  180 + totalPrice: item.totalPayment,
  181 + };
  182 + })}
171 rules={[ 183 rules={[
172 { 184 {
173 required: true, 185 required: true,
@@ -180,9 +192,98 @@ export default ({ dataList, mainOrder, setVisible, onClose }) =&gt; { @@ -180,9 +192,98 @@ export default ({ dataList, mainOrder, setVisible, onClose }) =&gt; {
180 }, 192 },
181 }, 193 },
182 ]} 194 ]}
183 - >  
184 - <InvoiceProjectSelect readOnly={true} />  
185 - </ProFormList> 195 + itemRender={(doms, listMeta) => {
  196 + console.log(listMeta);
  197 + return (
  198 + <ProCard
  199 + bordered
  200 + extra={doms.action}
  201 + title={'明细' + (listMeta.index + 1)}
  202 + style={{
  203 + marginBlockEnd: 8,
  204 + }}
  205 + >
  206 + <ProFormSelect
  207 + key={'projectName' + listMeta.index}
  208 + width="md"
  209 + name="projectName"
  210 + request={async (value) => {
  211 + const keywords = value.keyWords;
  212 + const res = await postServiceConstListInvoiceDetailNames({
  213 + data: {
  214 + nameLike: keywords,
  215 + },
  216 + });
  217 + let options = res?.data?.map((c: any) => {
  218 + return {
  219 + ...c,
  220 + label: c.name,
  221 + value:
  222 + '*' +
  223 + c.productAndServiceCatagoryAbbreviation +
  224 + '*' +
  225 + c?.name,
  226 + key: c.id,
  227 + };
  228 + });
  229 + return options;
  230 + }}
  231 + fieldProps={{
  232 + filterOption() {
  233 + return true;
  234 + },
  235 + }}
  236 + onChange={(_, option) => {
  237 + let index = listMeta.index;
  238 + let copyList = form.getFieldValue('invoiceDetails');
  239 + let currentData = copyList[index];
  240 + currentData.projectName =
  241 + '*' +
  242 + option.productAndServiceCatagoryAbbreviation +
  243 + '*' +
  244 + option.name;
  245 + currentData.specification = option.specification;
  246 + currentData.unit = option.unit;
  247 + form.setFieldValue('invoiceDetails', copyList);
  248 + }}
  249 + debounceTime={1000}
  250 + label="项目名称"
  251 + placeholder="请输入名称"
  252 + />
  253 + <ProFormText
  254 + key={'specification' + listMeta.index}
  255 + name="specification"
  256 + label="规格型号"
  257 + placeholder="请输入名称"
  258 + />
  259 + <ProFormText
  260 + key={'unit' + listMeta.index}
  261 + name="unit"
  262 + label="单位"
  263 + placeholder="请输入名称"
  264 + />
  265 + <ProFormDigit
  266 + key={'quantity' + listMeta.index}
  267 + label="数量"
  268 + name="quantity"
  269 + min={0}
  270 + />
  271 + <ProFormDigit
  272 + key={'price' + listMeta.index}
  273 + label="单价"
  274 + name="price"
  275 + min={0}
  276 + />
  277 + <ProFormMoney
  278 + key={'totalPrice' + listMeta.index}
  279 + label="金额"
  280 + name="totalPrice"
  281 + locale="zh-CN"
  282 + />
  283 + </ProCard>
  284 + );
  285 + }}
  286 + ></ProFormList>
186 <ProFormTextArea 287 <ProFormTextArea
187 name="applyInvoicingNotes" 288 name="applyInvoicingNotes"
188 label="备注" 289 label="备注"