123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <div class="edit-order-content-container">
- <createOrder ref="createOrder" :readonly="readonlyC" />
- </div>
- </template>
- <script>
- import createOrder from './create.vue'
- import { mapState, mapActions } from 'vuex'
- import { pageFormState } from '@/views/create-order/mixins'
- import { ajaxGetOrderDetail } from '@/api/modules'
- import { showMessage, showNotify } from '@/views/create-order/hooks/toast'
- const successMsgMap = {
- 1: '订单暂存成功',
- 2: '订单修改成功',
- }
- export default {
- name: 'EditOrderContent',
- mixins: [pageFormState],
- components: {
- createOrder,
- },
- props: {
- type: {
- type: String,
- default: 'edit',
- validator(v) {
- return ['edit', 'read'].includes(v)
- }
- },
- orderCode: {
- type: String,
- default: '',
- },
- readonly: {
- type: Boolean,
- default: false,
- },
- autoGetDetail: {
- type: Boolean,
- default: false,
- },
- },
- computed: {
- ...mapState({
- pageForm: state => state.order.pageForm,
- }),
- readonlyC() {
- return this.type === 'read' || this.readonly
- }
- },
- watch: {
- orderCode: {
- immediate: true,
- handler(n) {
- this.getOrderDetail(n)
- }
- }
- },
- methods: {
- ...mapActions('order', ['createOrder', 'resetPageInfo', 'restorePageInfo']),
- async getOrderDetail(orderCode) {
- if (!orderCode) return
- this.resetPageInfo()
- const { error_code: code, data, error_msg: msg } = await ajaxGetOrderDetail({ orderCode })
- if (code === 0) {
- if (data) {
- this.restorePageInfo(data)
- this.emitDetail(data)
- } else {
- showNotify({ message: '未查询到订单数据' })
- }
- } else {
- if (msg) {
- showNotify({ message: msg || '获取订单详情失败' })
- }
- }
- },
- emitDetail(order) {
- this.$emit('detail', order)
- },
- getFormRefs() {
- return this.$refs.createOrder.getFormRefs()
- },
- async doSave(save) {
- if (!this.orderCode) {
- return console.error('未传入orderCode')
- }
- const id = await this.createOrder({ save, orderCode: this.orderCode })
- if (id) {
- const msg = successMsgMap[save]
- this.$toast(msg)
- }
- },
- async submit() {
- // 提交
- await this.doSave(2)
- this.resetPageInfo()
- },
- async stash() {
- // 暂存
- await this.doSave(1)
- this.resetPageInfo()
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep {
- .el-form-item {
- margin-bottom: 12px;
- }
- .el-form-item__label {
- color: #686868;
- }
- .el-form-item__error {
- padding-top: 0;
- }
- .el-select-w100.el-select {
- width: 100%;
- }
- .el-input__inner,
- .el-textarea__inner {
- color: $gray_10;
- // &:focus {
- // outline: 0;
- // box-shadow: 0 0 0 2px rgba($main,.2);
- // }
- }
- .form-item-container {
- font-size: 14px;
- line-height: 22px;
- .form-item-label {
- color: #686868;
- }
- .form-item-value {
- color: $gray_10;
- }
- }
- }
- .create-order-content-container {
- position: relative;
-
- &.readonly {
- // &::after,
- .readonly-overlay {
- content: '';
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- z-index: 99999;
- /* 遮罩层显示时捕获所有指针事件 */
- pointer-events: auto;
- }
- }
- }
- .create-order-module {
- font-size: 14px;
- }
- </style>
|