123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <el-dialog
- :visible.sync="visible"
- :title="`订单详情 ${oData && oData.orderNo ? oData.orderNo : ''}`"
- append-to-body
- width="1200px"
- >
- <div class="flex column" style="padding-bottom:20px;height:580px">
- <div class="flex valign-center">
- <el-button
- plain
- icon="el-icon-delete"
- type="primary"
- size="small"
- class="custom-plain-button"
- @click="onBatchDeleteBtnClick"
- :disabled="selectedList.length === 0 || (oData.tagApplyStateId !='0' && oData.tagApplyStateId != '1')"
- >批量删除</el-button>
- </div>
- <div class="flex-1 fit-size" style="padding-top:20px;">
- <el-table
- ref="table"
- :data="list"
- stripe
- border
- height="100%"
- size="small"
- class="custom-el-table-style"
- @selection-change="onSelectionChange"
- @row-click="onRowClick"
- >
- <el-table-column
- type="selection"
- width="55"
- align="center"
- :selectable="tagSelectAble"
- fixed
- ></el-table-column>
- <el-table-column
- type="index"
- label="序号"
- width="60"
- align="center"
- fixed
- ></el-table-column>
- <el-table-column
- label="商品编码"
- prop="goodsCode"
- header-align="center"
- min-width="100"
- align="center"
- ></el-table-column>
- <el-table-column
- label="商品名称"
- min-width="200"
- prop="goodsName"
- header-align="center"
- align="center"
- ></el-table-column>
- <el-table-column
- label="物料编码"
- min-width="100"
- prop="materielCode"
- header-align="center"
- align="center"
- ></el-table-column>
- <el-table-column
- label="最小包装数量"
- min-width="80"
- prop="minimumPackingNumber"
- header-align="center"
- align="center"
- ></el-table-column>
- <el-table-column
- label="最小包装单位"
- min-width="80"
- prop="minimumPackingUnit"
- header-align="center"
- align="center"
- ></el-table-column>
- <el-table-column
- label="数量"
- min-width="80"
- prop="number"
- header-align="center"
- align="center"
- >
- <template slot-scope="scope">
- <el-input v-model="scope.row.number" :class="{ 'input-error': scope.row.number === '' }" @input="handleInput" :disabled="oData.tagApplyStateId !='0' && oData.tagApplyStateId != '1'"></el-input>
- </template>
- </el-table-column>
- <el-table-column
- label="单价(元)"
- prop="unitPrice"
- align="right"
- min-width="70"
- header-align="center"
- ></el-table-column>
- <el-table-column
- label="费用(元)"
- prop="amount"
- align="right"
- min-width="70"
- header-align="center"
- ></el-table-column>
- <el-table-column
- label="标签类型"
- prop="tagTypeName"
- align="left"
- min-width="120"
- header-align="center"
- ></el-table-column>
- <el-table-column
- label="操作栏"
- min-width="80"
- header-align="center"
- align="center"
- >
- <template v-slot="{ row }">
- <div class="flex center layout-gap">
- <edit-button :data="row" :on-click="onDeleteBtnClick" icon="el-icon-delete" :disabled="oData.tagApplyStateId !='0' && oData.tagApplyStateId != '1'">删除</edit-button>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <template #footer v-if="oData && (oData.tagApplyStateId === '0'||oData.tagApplyStateId === '1')">
- <div class="flex center dialog-footer">
- <el-button
- @click="onCloseBtnClick"
- >取消</el-button>
- <el-button
- type="primary"
- @click="onOkBtnClick"
- >确定</el-button>
- </div>
- </template>
- </el-dialog>
- </template>
- <script>
- import BaseCurdList from '@@/utils/BaseCurdList'
- import TagApply from '@@/entries/TagApply'
- export default {
- name: 'DialogTagApplyDetail',
- extends: BaseCurdList(TagApply),
- props: {
- api: {
- required: true,
- type: Function
- }
- },
- data: () => ({
- visible: false,
- oData: null
- }),
- methods: {
- open (data) {
- this.oData = data
- this.visible = true
- this.list = data.details
- },
- close () {
- this.oData = null
- this.visible = false
- this.list = Object.freeze([])
- },
- tagSelectAble () {
- return this.oData.tagApplyStateId === '0' || this.oData.tagApplyStateId === '1'
- },
- onBatchDeleteBtnClick () {
- const { selectedList } = this
- this.$confirm(`此操作将删除选中的记录, 是否继续?`, '确认', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- confirmButtonClass: 'confirm-dialog-confirm-btn',
- cancelButtonClass: 'confirm-dialog-cancel-btn',
- type: 'warning'
- }).then(() => {
- const ids = new Set(selectedList.map(data => data.id))
- this.list = this.list.filter(item => !ids.has(item.id))
- this.oData.details = this.list
- }).catch(() => {})
- },
- onDeleteBtnClick (data) {
- this.$confirm(`此操作将删除该记录, 是否继续?`, '确认', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- confirmButtonClass: 'confirm-dialog-confirm-btn',
- cancelButtonClass: 'confirm-dialog-cancel-btn',
- type: 'warning'
- }).then(() => {
- this.list = this.list.filter(item => item.id !== data.id)
- this.oData.details = this.list
- }).catch(() => {})
- },
- onCloseBtnClick () {
- this.close()
- },
- onOkBtnClick () {
- this.$$request(this.api, this.oData).then(() => {
- this.close()
- this.$emit('saved')
- }).catch(console.error).finally(() => {})
- },
- handleInput (value) {
- let sanitizedValue = value.replace(/[^0-9]/g, '')
- sanitizedValue = sanitizedValue.replace(/^0+/, '')
- this.selectedData.number = sanitizedValue === '' ? '' : sanitizedValue
- this.selectedData.amount = sanitizedValue === '' ? 0 : (sanitizedValue * this.selectedData.unitPrice).toFixed(2)
- }
- }
- }
- </script>
- <style lang="scss">
- .input-error .el-input__inner {
- border-color: red;
- }
- </style>
|