UNPKG

ttk-app-core

Version:
701 lines (694 loc) 34.7 kB
import { consts, common } from 'edf-constant' import moment from 'moment' import { fromJS } from 'immutable' export function getMeta() { return { name: 'root', component: 'Layout', className: 'app-sa-delivery-card', id: 'app-sa-delivery-card', onMouseDown: '{{$mousedown}}', children: [{ name: 'header', component: 'Layout', className: 'app-sa-delivery-card-header', children: [{ name: 'left', component: 'Layout', className: 'app-sa-delivery-card-header-left', children: [{ name: 'page', component: 'Button.Group', className: 'page-prev-next', children: [{ name: 'prev', component: 'Button', icon: 'left', title: '上一张', disabled: '{{data.other.prevDisalbed}}', onClick: '{{$prev}}' }, { name: 'next', component: 'Button', icon: 'right', title: '下一张', disabled: '{{data.other.nextDisalbed}}', onClick: '{{$next}}' }] }, { name: 'setting', component: 'Icon', className: 'btn setting', fontFamily: 'edficon', type: 'shezhi', title: '设置', onClick: '{{$setting}}' }, { name: 'shortcut', component: 'Popover', placement: "bottom", overlayClassName: 'app-sa-delivery-card-header-left-jianpan', arrowPointAtCenter: true, content: { name: 'keys', component: 'ShortKey' }, title: null, children: { component: 'Icon', className: 'app-sa-delivery-card-header-left-iconbutton', fontFamily: 'edficon', type: 'jianpan', title: '快捷键', } }] }, { name: 'right', component: 'Layout', className: 'app-sa-delivery-card-header-right', children: [{ name: 'add', component: 'Button', className: 'app-pu-arrival-card-header-right-but', onClick: '{{function(){$save(true)}}}', disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}', children: '保存并新增' }, { name: 'audit', component: 'Button', disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}', _visible: '{{data.other.auditVisible}}', onClick: '{{$audit}}', children: '{{$getAuditBtnText()}}' }, { name: 'history', component: 'Button', onClick: '{{$history}}', children: '历史单据' }, { name: 'more', component: 'Dropdown', overlay: { name: 'menu', component: 'Menu', onClick: '{{$moreMenuClick}}', children: [{ name: 'del', component: 'Menu.Item', key: 'del', disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY || data.other.pageStatus === data.consts.pageStatus.ADD}}', children: '删除' },/* { name: 'generateReturn', component: 'Menu.Item', key: 'generateReturn', disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}', children: '生成红字销售订单' },{ name: 'antiAudit', component: 'Menu.Item', key: 'antiAudit', // onClick: '{{$audit}}', disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}', children: '反审核' }, */{ name: 'receive', component: 'Menu.Item', key: 'receive', // disabled: '{{!data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}', disabled: `{{data.other.pageStatus === data.consts.pageStatus.EDIT || data.other.pageStatus === data.consts.pageStatus.ADD || data.form.receiveAmount == data.form.taxInclusiveAmount || data.form.taxInclusiveAmount < 0 }}`, children: '收款' }] }, children: { name: 'internal', component: 'Button', children: ['更多', { name: 'down', component: 'Icon', type: 'down' }] } }] }] }, { name: 'content', component: '::div', className: 'app-pu-arrival-card-content', children: [{ name: 'title', component: 'Layout', className: 'app-sa-delivery-card-title', children: [{ name: 'left', component: 'Layout', className: 'app-sa-delivery-card-title-left', children: [{ name: 'audited', component: '::img', className: 'app-sa-delivery-card-title-left-tag', src: require('./img/audited.png'), _visible: '{{data.form.status == data.consts.VOUCHERSTATUS_Approved}}' }, // { // name: 'settleStatus', // component: '::img', // className: 'app-sa-delivery-card-title-left-tag', // src: require('./img/settled.png'), // _visible: '{{data.form.settleStatus == data.consts.SETTLESTATUS_settled}}' // } ] }, { name: 'center', component: '::div', className: 'app-sa-delivery-card-title-center', children: { name: 'title', component: '::h1', style: { fontWeight: 'bold' }, children: '销售单' } }, { name: 'right', component: 'Layout', className: 'app-sa-delivery-card-title-right', children: ['单据编号:', { name: 'code', component: '::div', className: 'code', style: { marginRight: 10 }, children: "{{data.form.code || ''}}" }, { name: 'attachmentItem', component: 'Attachment', status: '{{data.form.attachmentStatus}}', data: '{{data.form.attachmentFiles}}', onDownload: '{{$download}}', loading: '{{data.form.attachmentLoading}}', visible: '{{data.form.attachmentVisible}}', onDel: '{{$delFile}}', uploadProps: { action: '/v1/edf/file/upload', //上传地址, headers: '{{$getAccessToken()}}', accept: '', //接受的上传类型 data: { "fileClassification": "ATTACHMENT" }, onChange: '{{$attachmentChange}}', beforeUpload: '{{$beforeUpload}}' } }] }] }, { name: 'formHeader', component: 'Form', className: 'app-sa-delivery-card-form-header', //_notRender: "{{data.other.isRender !=true}}", children: '{{$renderFormContent()}}' }, { name: 'details', component: 'DataGrid', className: 'app-sa-delivery-card-form-details', headerHeight: 35, rowHeight: 35, footerHeight: 35, rowsCount: '{{data.form.details.length}}', enableSequence: true, enableSequenceAddDelrow: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY ? false : true}}', startSequence: 1, sequenceFooter: { name: 'footer', component: 'DataGrid.Cell', children: '合计' }, readonly: false, onAddrow: "{{$addRow('details')}}", onDelrow: "{{$delRow('details')}}", onUprow: "{{$upRow('details')}}", onDownrow: "{{$downRow('details')}}", onKeyDown: '{{$gridKeydown}}', scrollToColumn: '{{data.other.detailsScrollToColumn}}', scrollToRow: '{{data.other.detailsScrollToRow}}', key: '{{data.other.detailHeight}}', style: '{{{return{height: data.other.detailHeight}}}}', columns: [{ name: 'inventoryCode', component: 'DataGrid.Column', columnKey: 'inventoryCode', flexGrow: 1, width: 90, _visible: '{{$getColumnVisible("inventoryCode")}}', header: { name: 'header', component: 'DataGrid.Cell', className: 'ant-form-item-required', children: '存货编码' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath)}}', showSearch: true, value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].inventoryCode}}', onChange: '{{$onFieldChange({ code: `data.form.details.${_rowIndex}.inventoryCode`,' + 'id: `data.form.details.${_rowIndex}.inventoryId`,' + 'name: `data.form.details.${_rowIndex}.inventoryName`,' + // 'revenueType: `data.form.details.${_rowIndex}.revenueType`,' + // 'revenueTypeName: `data.form.details.${_rowIndex}.revenueTypeName`,' + 'unitId: `data.form.details.${_rowIndex}.unitId`,' + 'unitName: `data.form.details.${_rowIndex}.unitName`,' + 'specification: `data.form.details.${_rowIndex}.specification`}, "data.other.inventory", _rowIndex, data.form.details[_rowIndex])}}', onFocus: '{{function(){$getInventory({}, `data.other.inventory`)}}}', filterOption: '{{$filterOption}}', // dropdownFooter:"{{$handleAddRecord('Inventory', 'inventory', _rowIndex, data.form.details[_rowIndex])}}", children: { name: 'option', component: 'Select.Option', value: '{{data.other.inventory && data.other.inventory[_lastIndex].id}}', children: '{{data.other.inventory && data.other.inventory[_lastIndex].code}}', _power: 'for in data.other.inventory' }, _excludeProps: '{{$isFocus(_ctrlPath) ? ["onClick"] : ["children"]}}', _power: '({rowIndex}) => rowIndex', } }, { name: 'inventoryName', component: 'DataGrid.Column', columnKey: 'inventoryName', flexGrow: 1, width: 100, header: { name: 'header', component: 'DataGrid.Cell', className: 'ant-form-item-required', children: '存货名称' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath)}}', showSearch: true, value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].inventoryName}}', onChange: '{{$onFieldChange({ id: `data.form.details.${_rowIndex}.inventoryId`,' + 'name: `data.form.details.${_rowIndex}.inventoryName`,' + 'code: `data.form.details.${_rowIndex}.inventoryCode`,' + // 'revenueType: `data.form.details.${_rowIndex}.revenueType`,' + // 'revenueTypeName: `data.form.details.${_rowIndex}.revenueTypeName`,' + 'unitId: `data.form.details.${_rowIndex}.unitId`,' + 'unitName: `data.form.details.${_rowIndex}.unitName`,' + // 'taxRateName: `data.form.details.${_rowIndex}.taxRateName`,' + 'specification: `data.form.details.${_rowIndex}.specification`}, "data.other.inventory", _rowIndex, data.form.details[_rowIndex])}}', onFocus: '{{function() {$getInventory({}, `data.other.inventory`)}}}', filterOption: '{{$filterOption}}', dropdownFooter: "{{$handleAddRecord('Inventory', 'inventory', _rowIndex, data.form.details[_rowIndex])}}", children: { name: 'option', component: 'Select.Option', value: '{{data.other.inventory && data.other.inventory[_lastIndex].id}}', children: '{{data.other.inventory && data.other.inventory[_lastIndex].name}}', _power: 'for in data.other.inventory' }, _excludeProps: '{{$isFocus(_ctrlPath) ? ["onClick"] : ["children"]}}', _power: '({rowIndex}) => rowIndex', } },/* { // name: 'revenueType', // component: 'DataGrid.Column', // columnKey: 'revenueType', // flexGrow: 1, // width: 120, // header: { // name: 'header', // component: 'DataGrid.Cell', // //className: 'ant-form-item-required', // children: '收入类型' // }, // cell: { // name: 'cell', // component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}', // className: '{{$getCellClassName(_ctrlPath)}}', // showSearch: false, // value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].revenueTypeName}}', // onChange: '{{$onFieldChange({ id: `data.form.details.${_rowIndex}.revenueType`,' + // 'name: `data.form.details.${_rowIndex}.revenueTypeName`}, "data.other.revenueType", _rowIndex, data.form.details[_rowIndex])}}', // // onFocus: '{{$getRevenueType}}', // onFocus: '{{function(){$getRevenueType({enumId:300012}, "data.other.revenueType")}}}', // children: { // name: 'option', // component: 'Select.Option', // value: '{{data.other.revenueType && data.other.revenueType[_lastIndex].id}}', // children: '{{data.other.revenueType && data.other.revenueType[_lastIndex].name}}', // _power: 'for in data.other.revenueType' // }, // _excludeProps: '{{$isFocus(_ctrlPath) ? ["onClick"] : ["children"]}}', // _power: '({rowIndex}) => rowIndex', // } }, */{ name: 'specification', component: 'DataGrid.Column', columnKey: 'specification', flexGrow: 1, width: 90, _visible: '{{$getColumnVisible("specification")}}', header: { name: 'header', component: 'DataGrid.Cell', children: '规格型号' }, cell: { name: 'cell', component: 'DataGrid.TextCell', className: "{{$getCellClassName(_ctrlPath) + ' app-sa-delivery-card-cell-disabled'}}", value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].specification}}', _power: '({rowIndex}) => rowIndex', } }, { name: 'unit', component: 'DataGrid.Column', columnKey: 'unit', flexGrow: 1, width: 80, _visible: '{{$getColumnVisible("unit")}}', header: { name: 'header', component: 'DataGrid.Cell', children: '计量单位' }, cell: { name: 'cell', component: 'DataGrid.TextCell', className: "{{$getCellClassName(_ctrlPath) + ' app-sa-delivery-card-cell-disabled'}}", value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].unitName}}', _power: '({rowIndex}) => rowIndex', } }, /*{ name: 'isGift', component: 'DataGrid.Column', columnKey: 'isGift', _visible: '{{$getControlVisible()}}', width: 100, header: { name: 'header', component: 'DataGrid.Cell', children: '赠品' }, cell: { name: 'cell', component: "{{$isFocus(_ctrlPath) ? 'Checkbox' : 'DataGrid.TextCell'}}", className: "{{$getCellClassName(_ctrlPath)}}", value: "{{ (data.form.details[_rowIndex] && data.form.details[_rowIndex].isGift) ? '': '' }}", checked: "{{ data.form.details[_rowIndex] && data.form.details[_rowIndex].isGift }}", onChange: "{{(e)=>$sf('data.form.details.' + _rowIndex + '.isGift', e.target.checked)}}", _power: '({rowIndex})=>rowIndex', } },*/ { name: 'quantity', component: 'DataGrid.Column', columnKey: 'quantity', flexGrow: 1, width: 100, header: { name: 'header', component: 'DataGrid.Cell', className: 'ant-form-item-required', children: '数量' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath) + " app-sa-delivery-card-cell-right"}}', value: '{{$quantityFormat(data.form.details[_rowIndex].quantity,2,$isFocus(_ctrlPath))}}', onChange: '{{$calc("quantity", _rowIndex, data.form.details[_rowIndex])}}', _power: '({rowIndex}) => rowIndex', }, footer: { name: 'footer', component: 'DataGrid.Cell', className: 'app-sa-delivery-card-list-cell-right', children: '{{$sumColumn("quantity")}}' } }, { name: 'price', component: 'DataGrid.Column', columnKey: 'price', flexGrow: 1, width: 100, header: { name: 'header', component: 'DataGrid.Cell', className: 'ant-form-item-required', children: '单价' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath) + " app-sa-delivery-card-cell-right"}}', value: '{{$quantityFormat(data.form.details[_rowIndex].price,6,$isFocus(_ctrlPath))}}', onChange: '{{$calc("price", _rowIndex,data.form.details[_rowIndex])}}', _power: '({rowIndex}) => rowIndex', } }, { name: 'amount', component: 'DataGrid.Column', columnKey: 'amount', flexGrow: 1, width: 100, header: { name: 'header', component: 'DataGrid.Cell', className: 'ant-form-item-required', children: '金额' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath) + " app-sa-delivery-card-cell app-sa-delivery-card-cell-right"}}', value: '{{$quantityFormat(data.form.details[_rowIndex].amount,2,$isFocus(_ctrlPath))}}', onChange: '{{$calc("amount", _rowIndex,data.form.details[_rowIndex])}}', _power: '({rowIndex}) => rowIndex', }, // footer: { // name: 'footer', // component: 'DataGrid.Cell', // className: 'app-sa-delivery-card-list-cell-right', // children: '{{$sumColumn("amount")}}' // } }, { name: 'taxRate', component: 'DataGrid.Column', columnKey: 'taxRate', flexGrow: 1, width: 100, _visible: '{{$getColumnVisible("taxRate")}}', header: { name: 'header', component: 'DataGrid.Cell', children: '税率' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath)}}', showSearch: false, value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].taxRateName}}', onChange: '{{$calc("taxRateName", _rowIndex, data.form.details[_rowIndex])}}', children: { name: 'option', component: 'Select.Option', value: '{{data.other.taxRate && data.other.taxRate[_lastIndex].id}}', children: '{{data.other.taxRate && data.other.taxRate[_lastIndex].name}}', _power: 'for in data.other.taxRate' }, _excludeProps: '{{$isFocus(_ctrlPath)? ["onClick"] : ["children"]}}', _power: '({rowIndex}) => rowIndex', } }, { name: 'tax', component: 'DataGrid.Column', columnKey: 'tax', flexGrow: 1, width: 100, _visible: '{{$getColumnVisible("tax")}}', header: { name: 'header', component: 'DataGrid.Cell', children: '税额' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath) + " app-sa-delivery-card-cell app-sa-delivery-card-cell-right"}}', value: '{{$quantityFormat(data.form.details[_rowIndex].tax,2,$isFocus(_ctrlPath))}}', onChange: '{{$calc("tax", _rowIndex, data.form.details[_rowIndex])}}', _power: '({rowIndex}) => rowIndex', }, footer: { name: 'footer', component: 'DataGrid.Cell', className: 'app-sa-delivery-card-list-cell-right', children: '{{$sumColumn("tax")}}' } }, { name: 'taxInclusiveAmount', component: 'DataGrid.Column', columnKey: 'taxInclusiveAmount', flexGrow: 1, width: 100, _visible: '{{$getColumnVisible("taxInclusiveAmount")}}', header: { name: 'header', component: 'DataGrid.Cell', children: '价税合计' }, cell: { name: 'cell', component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}', className: '{{$getCellClassName(_ctrlPath) + " app-sa-delivery-card-cell app-sa-delivery-card-cell-right"}}', value: '{{$quantityFormat(data.form.details[_rowIndex].taxInclusiveAmount,2,$isFocus(_ctrlPath))}}', onChange: '{{$calc("taxInclusiveAmount", _rowIndex, data.form.details[_rowIndex])}}', _power: '({rowIndex}) => rowIndex', }, footer: { name: 'footer', component: 'DataGrid.Cell', className: 'app-sa-delivery-card-list-cell-right', children: '{{$sumColumn("taxInclusiveAmount")}}' } }] }, { name: 'formFooter', component: '::div', className: 'app-sa-delivery-card-form-footer', children: [{ name: 'settlement', component: 'Form', className: 'app-sa-delivery-card-form-footer-settlement', children: [{ name: 'payDiv', component: '::div', className: 'app-pu-arrival-card-form-footer-settlement-payDiv', children: '{{$renderPayDiv()}}' }] }] }, { name: 'balanceItem', component: '::div', className: 'app-sa-delivery-card-form-footer-balance-signRight', children: [{ name: 'balanceAdvanceS', component: '::span', children: '剩余金额:' }, { name: 'balanceAdvance', component: '::span', style: '{{{return (data.other.isDisableBank ? {color: "rgba(0, 0, 0, 0.25)"} : {})}}}', children: '{{$calcBalance(data)}}' }] }, { name: 'footer', component: 'Layout', className: 'app-sa-delivery-card-footer', children: [{ name: 'left', component: 'Layout', className: 'app-sa-delivery-card-footer-left', children: [{ name: 'creator', component: 'Layout', children: ['制单人:', '{{data.form.creatorName}}'], style: { marginRight: 30 } }, { name: 'approver', component: 'Layout', children: ['审核人:', '{{data.form.auditorName}}'], }] }, { name: 'right', component: 'Layout', className: 'app-sa-delivery-card-footer-right', children: [{ name: 'saveAndNew', component: 'Button', className: 'app-pu-arrival-card-footer-right-but', onClick: '{{function() {$save(true)}}}', disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}', children: '保存并新增' }, { name: 'save', component: 'Button', onClick: '{{function(){$save(false)}}}', disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}', children: '保存' }, { name: 'cancel', component: 'Button', onClick: '{{$add}}', disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}', children: '放弃' }] }] }] },] } } export function getInitState() { return { data: { form: { details: [ blankDetail, blankDetail, blankDetail, blankDetail, blankDetail, // blankDetail ], settles: [{ bankAccountId: '', amount: '', bankAccountName: '' }] }, total: { }, other: { pageStatus: common.commonConst.PAGE_STATUS.ADD, signAndRetreat: [{ id: 4000100001, name: "即征即退", }, { id: 4000100002, name: "一般项目", }], // isSignAndRetreat: true, defaultLength: 5, //默认初始行数 MOVEROW_UP: 0, MOVEROW_DOWN: 1, detailHeight: '245px', isDisableBank: false, auditVisible: false }, consts: { VOUCHERSTATUS_Approved: consts.consts.VOUCHERSTATUS_Approved, SETTLESTATUS_settled: consts.consts.SETTLESTATUS_settled, pageStatus: common.commonConst.PAGE_STATUS } } } } export const blankDetail = { // warehouseId: null, inventoryId: null, unitId: null, quantity: null, // isGift: null, price: null, // taxInclusivePrice: null, taxRateId: null, // taxRate:null, tax: null, amount: null, taxInclusiveAmount: null }