大宝管理后台代码
123
dcc
2024-05-29 52e4976e00a512c7cfe554330517559c4e919aba
src/views/newshares/newshareslist.vue
@@ -33,26 +33,26 @@
            </a-col>
          </a-row>
          <a-row :gutter="48">
            <a-col :md="12" :lg="6" :sm="24">
              <a-form-item>
                <span class="table-page-search-submitButtons">
                  <a-button @click="getqueryParam" icon="redo">
                    重置</a-button>
                  <a-button @click="getqueryParam" icon="redo"> 重置</a-button>
                  <a-button
                    type="primary"
                    icon="search"
                    style="margin-left: 8px"
                    @click="queryParam.pageNum = 1, pagination.current = page,getlist()">查询
                    @click=";(queryParam.pageNum = 1), (pagination.current = page), getlist()"
                  >查询
                  </a-button>
                  <a-button
                    type="primary"
                    icon="plus"
                    style="margin-left: 8px"
                    @click="addUserdialog = true, currentdetail = ''">
                    添加新股</a-button>
                    @click=";(addUserdialog = true), (currentdetail = '')"
                  >
                    添加新股</a-button
                  >
                </span>
              </a-form-item>
            </a-col>
@@ -68,17 +68,17 @@
        :pagination="pagination"
        :columns="columns"
        :data-source="datalist"
        rowKey="newlistId">
        <span slot="name" slot-scope="text,record">
        rowKey="newlistId"
      >
        <span slot="name" slot-scope="text, record">
          <template>
            <div>
              <span style="margin-right:10px">{{ record.name }}</span>
              <a-tag color="green">{{ record.code }}
              </a-tag>
              <span style="margin-right: 10px">{{ record.name }}</span>
              <a-tag color="green">{{ record.code }} </a-tag>
            </div>
          </template>
        </span>
        <span slot="zt" slot-scope="text,record">
        <span slot="zt" slot-scope="text, record">
          <template>
            <div>
              <a-tag :color="record.zt == 0 ? 'green' : record.zt == 1 ? 'red' : ''">
@@ -87,7 +87,7 @@
            </div>
          </template>
        </span>
        <span slot="type" slot-scope="text,record">
        <span slot="type" slot-scope="text, record">
          <template>
            <div>
              <a-tag :color="record.type == 1 ? 'purple' : record.type == 2 ? 'blue' : ''">
@@ -96,20 +96,17 @@
            </div>
          </template>
        </span>
        <span slot="stockType" slot-scope="text,record">
        <span slot="stockType" slot-scope="text, record">
          <template>
            <div>
              <a-tag
                :color="record.stockType == 'sh' ? 'purple' : record.stockType == 'sz' ? 'blue' : ''">
                {{ record.stockType == 'sh' ? '沪股' : record.stockType == 'sz' ? '深股' :
                  record.stockType
                }}
              <a-tag :color="record.stockType == 'sh' ? 'purple' : record.stockType == 'sz' ? 'blue' : ''">
                {{ record.stockType == 'sh' ? '沪股' : record.stockType == 'sz' ? '深股' : record.stockType }}
              </a-tag>
            </div>
          </template>
        </span>
        <template slot="action" slot-scope="text,record">
        <template slot="action" slot-scope="text, record">
          <a slot="action" href="javascript:;" @click="geteditStock(record)">{{ '修改新股' }}</a>
          <!-- <a-divider type="vertical" /> -->
          <!-- <a slot="action" href="javascript:;" @click="getdeleteStock(record)">{{ '删除新股' }}</a> -->
@@ -123,21 +120,24 @@
      :visible="addUserdialog"
      :confirmLoading="addUserDialogloading"
      @ok="OkaddUserdialog"
      @cancel="CanceladdUserdialog">
      @cancel="CanceladdUserdialog"
    >
      <a-form :form="addUserform" ref="addUserform">
        <a-row :gutter="48">
          <a-col :md="12" :lg="12" :sm="12">
            <a-form-item label="新股名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                placeholder="请输入新股名称"
                v-decorator="['name', { rules: [{ required: true, message: '请输入新股名称', }] }]" />
                v-decorator="['name', { rules: [{ required: true, message: '请输入新股名称' }] }]"
              />
            </a-form-item>
          </a-col>
          <a-col :md="12" :lg="12" :sm="12">
            <a-form-item label="新股代码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                placeholder="请输入新股代码"
                v-decorator="['code', { rules: [{ required: true, message: '请输入新股代码', }] }]" />
                v-decorator="['code', { rules: [{ required: true, message: '请输入新股代码' }] }]"
              />
            </a-form-item>
          </a-col>
        </a-row>
@@ -146,14 +146,16 @@
            <a-form-item label="新股价格" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                placeholder="请输入新股价格"
                v-decorator="['price', { rules: [{ required: true, message: '请输入新股价格', }] }]" />
                v-decorator="['price', { rules: [{ required: true, message: '请输入新股价格' }] }]"
              />
            </a-form-item>
          </a-col>
          <a-col :md="12" :lg="12" :sm="12">
            <a-form-item label="最大购买数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                placeholder="请输入最大购买数量"
                v-decorator="['orderNumber', { rules: [{ required: true, message: '请输入最大购买数量', }] }]" />
                v-decorator="['orderNumber', { rules: [{ required: true, message: '请输入最大购买数量' }] }]"
              />
            </a-form-item>
          </a-col>
        </a-row>
@@ -162,7 +164,8 @@
            <a-form-item label="股票类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select
                placeholder="请选择股票类型"
                v-decorator="['stockType', { rules: [{ required: true, message: '请选择股票类型', }] }]">
                v-decorator="['stockType', { rules: [{ required: true, message: '请选择股票类型' }] }]"
              >
                <a-select-option :value="'nse'">nse</a-select-option>
                <a-select-option :value="'bse'">bse</a-select-option>
              </a-select>
@@ -172,7 +175,8 @@
            <a-form-item label="新股模式" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select
                placeholder="请选择新股模式"
                v-decorator="['type', { rules: [{ required: true, message: '请选择新股模式', }] }]">
                v-decorator="['type', { rules: [{ required: true, message: '请选择新股模式' }] }]"
              >
                <a-select-option :value="1">新股申购</a-select-option>
                <a-select-option :value="2">线下配售</a-select-option>
              </a-select>
@@ -184,7 +188,8 @@
            <a-form-item label="显示状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select
                placeholder="请选择显示状态"
                v-decorator="['zt', { rules: [{ required: true, message: '请选择显示状态', }] }]">
                v-decorator="['zt', { rules: [{ required: true, message: '请选择显示状态' }] }]"
              >
                <a-select-option :value="0">显示</a-select-option>
                <a-select-option :value="1">隐藏</a-select-option>
              </a-select>
@@ -194,10 +199,11 @@
            <a-form-item label="申购时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-date-picker
                show-time
                style="width:100%"
                style="width: 100%"
                @change="getsubscribeTime"
                v-decorator="['subscribeTime', { rules: [{ required: true, message: '请填写申购时间', }] }]"
                format="YYYY-MM-DD HH:mm:ss">
                v-decorator="['subscribeTime', { rules: [{ required: true, message: '请填写申购时间' }] }]"
                format="YYYY-MM-DD HH:mm:ss"
              >
              </a-date-picker>
            </a-form-item>
          </a-col>
@@ -207,20 +213,33 @@
            <a-form-item label="认缴时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-date-picker
                show-time
                style="width:100%"
                style="width: 100%"
                @change="getsubscriptionTime"
                v-decorator="['subscriptionTime', { rules: [{ required: true, message: '请填写认缴时间', }] }]"
                format="YYYY-MM-DD HH:mm:ss">
                v-decorator="['subscriptionTime', { rules: [{ required: true, message: '请填写认缴时间' }] }]"
                format="YYYY-MM-DD HH:mm:ss"
              >
              </a-date-picker>
            </a-form-item>
          </a-col>
         <!-- <a-col :md="12" :lg="12" :sm="12">
            <a-form-item label="预估价格" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                placeholder="请输入预估价格"
                v-decorator="['pe', { rules: [{ required: true, message: '请输入预估价格', }] }]" />
          <a-col :md="12" :lg="12" :sm="12">
            <a-form-item label="上市时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-date-picker
                show-time
                style="width: 100%"
                @change="getListDate"
                v-decorator="['listDate', { rules: [{ required: true, message: '请填写上市时间' }] }]"
                format="YYYY-MM-DD HH:mm:ss"
              >
              </a-date-picker>
            </a-form-item>
          </a-col> -->
          </a-col>
          <a-col :md="12" :lg="12" :sm="12">
            <a-form-item label="最低数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input
                placeholder="请输入最低数量"
                v-decorator="['minOrderNumber', { rules: [{ required: true, message: '请输入最低数量', }] }]" />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-modal>
@@ -231,247 +250,282 @@
import moment from 'moment'
import pick from 'lodash.pick'
export default {
    name: 'Shares',
    data () {
        return {
            columns: [
                {
                    title: '新股名称 / 新股代码',
                    dataIndex: 'name',
                    align: 'center',
                    scopedSlots: { customRender: 'name' }
                },
                {
                    title: '最大购买数量',
                    dataIndex: 'orderNumber',
                    align: 'center'
                },
                // {
                //     title: '预估价格',
                //     dataIndex: 'pe',
                //     align: 'center'
                // },
                {
                    title: '价格',
                    dataIndex: 'price',
                    align: 'center'
                },
                {
                    title: '是否显示',
                    dataIndex: 'zt',
                    align: 'center',
                    scopedSlots: { customRender: 'zt' }
                },
                {
                    title: '新股模式',
                    dataIndex: 'type',
                    align: 'center',
                    scopedSlots: { customRender: 'type' }
                },
                {
                    title: '股票类型',
                    dataIndex: 'stockType',
                    align: 'center',
                    scopedSlots: { customRender: 'stockType' }
                },
  name: 'Shares',
  data () {
    return {
      columns: [
        {
          title: '新股名称 / 新股代码',
          dataIndex: 'name',
          align: 'center',
          scopedSlots: { customRender: 'name' }
        },
        {
          title: '最大购买数量',
          dataIndex: 'orderNumber',
          align: 'center'
        },
        // {
        //     title: '预估价格',
        //     dataIndex: 'pe',
        //     align: 'center'
        // },
        {
          title: '价格',
          dataIndex: 'price',
          align: 'center'
        },
        {
          title: '是否显示',
          dataIndex: 'zt',
          align: 'center',
          scopedSlots: { customRender: 'zt' }
        },
        {
          title: '新股模式',
          dataIndex: 'type',
          align: 'center',
          scopedSlots: { customRender: 'type' }
        },
        {
          title: '股票类型',
          dataIndex: 'stockType',
          align: 'center',
          scopedSlots: { customRender: 'stockType' }
        },
        {
          title: '最低数量',
          dataIndex: 'minOrderNumber',
          align: 'center',
          scopedSlots: { customRender: 'minOrderNumber' }
        },
                {
                    title: '申购时间',
                    dataIndex: 'subscribeTime',
                    align: 'center',
                    customRender: (text, row, index) => {
                        return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
                    }
                },
                {
                    title: '认缴时间',
                    dataIndex: 'subscriptionTime',
                    align: 'center',
                    customRender: (text, row, index) => {
                        return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
                    }
                },{
                    title: '上市时间',
                    dataIndex: 'listDate',
                    align: 'center',
                    customRender: (text, row, index) => {
                        return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
                    }
                },
                {
                    title: '操作',
                    key: 'action',
                    align: 'center',
                    scopedSlots: { customRender: 'action' }
                }
            ],
            disabledDate:true,
            // 表头
            pagination: {
                total: 0,
                current: 1,
                pageSize: 10, // 每页中显示10条数据
                showSizeChanger: true,
                pageSizeOptions: ['10', '20', '50', '100'], // 每页中显示的数据
                onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize), // 改变每页数量时更新显示
                onChange: (page, pageSize) => this.onPageChange(page, pageSize), // 点击页码事件
                showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
            },
            loading: false,
            queryParam: {
                pageNum: 1,
                pageSize: 10,
                code: '',
                name: '',
                zt: undefined,
                type: undefined
            },
            datalist: [],
            labelCol: {
                xs: { span: 8 },
                sm: { span: 8 },
                md: { span: 8 }
            },
            wrapperCol: {
                xs: { span: 14 },
                sm: { span: 14 },
                md: { span: 14 }
            },
            addUserform: this.$form.createForm(this),
            addUserdialog: false,
            addUserDialogloading: false,
            fields: ['name', 'code', 'price', 'orderNumber', 'zt', 'subscribeTime', 'subscriptionTime', 'type', 'stockType', 'code','pe','listDate'],
            currentdetail: '',
            subscribeTime: '',
            subscriptionTime: ''
        {
          title: '申购时间',
          dataIndex: 'subscribeTime',
          align: 'center',
          customRender: (text, row, index) => {
            return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
          }
        },
        {
          title: '认缴时间',
          dataIndex: 'subscriptionTime',
          align: 'center',
          customRender: (text, row, index) => {
            return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
          }
        },
        {
          title: '上市时间',
          dataIndex: 'listDate',
          align: 'center',
          customRender: (text, row, index) => {
            return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
          }
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
    },
    created () {
        this.getlist()
    },
    methods: {
        getdeleteStock (val) {
            var that = this
            this.$confirm({
                title: '提示',
                content: '确认删除该新股吗?此操作不可恢复!',
                onOk () {
                    var data = {
                        id: val.newlistId
                    }
                    subscribedel(data).then(res => {
                        if (res.status == 0) {
                            that.$message.success({ content: res.msg, duration: 2 })
                            that.getinit()
                        } else {
                            that.$message.error({ content: res.msg })
                        }
                    })
                },
                onCancel () {
                    console.log('Cancel')
                }
            })
        },
        getsubscribeTime (date, dateString) {
            this.subscribeTime = dateString
        },
        getsubscriptionTime (date, dateString) {
            this.subscriptionTime = dateString
        },
        geteditStock (val) {
            this.currentdetail = val
            this.addUserdialog = true
            var currentTime = new Date();
            this.fields.forEach(v => this.addUserform.getFieldDecorator(v))
            this.addUserform.setFieldsValue(pick(val, this.fields))
            this.addUserform.setFieldsValue({ subscriptionTime: moment(val.subscriptionTime?val.subscriptionTime:currentTime).format('YYYY-MM-DD HH:mm:ss') })
            this.addUserform.setFieldsValue({ subscribeTime: moment(val.subscribeTime?val.subscribeTime:currentTime).format('YYYY-MM-DD HH:mm:ss') })
             // this.subscribeTime = moment(val.subscribeTime).format('YYYY-MM-DD HH:mm:ss')
             // this.subscriptionTime  = moment(val.subscriptionTime).format('YYYY-MM-DD HH:mm:ss')
        },
        CanceladdUserdialog () {
            this.addUserdialog = false
            const form = this.$refs.addUserform.form
            form.resetFields()
        },
        OkaddUserdialog () {
            const form = this.$refs.addUserform.form
            form.validateFields((errors, values) => {
                if (!errors) {
                    if (this.currentdetail != '') {
                        this.addUserDialogloading = true
                        values.newlistId = this.currentdetail.newlistId
                        values.subscriptionTime = this.subscriptionTime
                        values.subscribeTime = this.subscribeTime
                        subscribeupdate(values).then(res => {
                            if (res.status == 0) {
                                this.addUserdialog = false
                                this.$message.success({ content: res.msg, duration: 2 })
                                form.resetFields()
                                this.getlist()
                            } else {
                                this.$message.error({ content: res.msg })
                            }
                            this.addUserDialogloading = false
                        })
                    } else {
                        this.addUserDialogloading = true
                        values.subscriptionTime = this.subscriptionTime
                        values.subscribeTime = this.subscribeTime
                        subscribeadd(values).then(res => {
                            if (res.status == 0) {
                                this.addUserdialog = false
                                this.$message.success({ content: res.msg, duration: 2 })
                                form.resetFields()
                                this.getinit()
                            } else {
                                this.$message.error({ content: res.msg })
                            }
                            this.addUserDialogloading = false
                        })
                    }
                }
            })
        },
        getqueryParam () {
            this.queryParam = {
                pageNum: 1,
                pageSize: 10,
                code: '',
                name: '',
                zt: undefined,
                type: undefined
            }
        },
        getinit () {
            this.getqueryParam()
            this.pagination.current = 1
            this.getlist()
        },
        getlist () {
            this.loading = true
            subscribelist(this.queryParam).then(res => {
                this.datalist = res.data.list
                this.pagination.total = res.data.total
                this.loading = false
            })
        },
        onPageChange (page, pageSize) {
            this.queryParam.pageNum = page
            this.pagination.current = page
            this.getlist()
        },
        onSizeChange (current, pageSize) {
            this.queryParam.pageNum = current
            this.pagination.current = page
            this.queryParam.pageSize = pageSize
            this.getlist()
        }
      ],
      disabledDate: true,
      // 表头
      pagination: {
        total: 0,
        current: 1,
        pageSize: 10, // 每页中显示10条数据
        showSizeChanger: true,
        pageSizeOptions: ['10', '20', '50', '100'], // 每页中显示的数据
        onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize), // 改变每页数量时更新显示
        onChange: (page, pageSize) => this.onPageChange(page, pageSize), // 点击页码事件
        showTotal: (total) => `共有 ${total} 条数据` // 分页中显示总的数据
      },
      loading: false,
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        code: '',
        name: '',
        zt: undefined,
        type: undefined
      },
      datalist: [],
      labelCol: {
        xs: { span: 8 },
        sm: { span: 8 },
        md: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 14 },
        sm: { span: 14 },
        md: { span: 14 }
      },
      addUserform: this.$form.createForm(this),
      addUserdialog: false,
      addUserDialogloading: false,
      fields: [
        'name',
        'code',
        'price',
        'orderNumber',
        'zt',
        'subscribeTime',
        'subscriptionTime',
        'type',
        'stockType',
        'code',
        'pe',
        'minOrderNumber',
        'listDate'
      ],
      currentdetail: '',
      subscribeTime: '',
      subscriptionTime: ''
    }
  },
  created () {
    this.getlist()
  },
  methods: {
    getdeleteStock (val) {
      var that = this
      this.$confirm({
        title: '提示',
        content: '确认删除该新股吗?此操作不可恢复!',
        onOk () {
          var data = {
            id: val.newlistId
          }
          subscribedel(data).then((res) => {
            if (res.status == 0) {
              that.$message.success(res.msg)
              that.getinit()
            } else {
              that.$message.error(res.msg)
            }
          })
        },
        onCancel () {
          console.log('Cancel')
        }
      })
    },
    getsubscribeTime (date, dateString) {
      this.subscribeTime = dateString
    },
    getsubscriptionTime (date, dateString) {
      this.subscriptionTime = dateString
    },
    getListDate (date, dateString) {
      this.listDate = dateString
    },
    geteditStock (val) {
      this.currentdetail = val
      this.addUserdialog = true
      var currentTime = new Date()
      this.fields.forEach((v) => this.addUserform.getFieldDecorator(v))
      this.addUserform.setFieldsValue(pick(val, this.fields))
      this.addUserform.setFieldsValue({
        subscriptionTime: moment(val.subscriptionTime ? val.subscriptionTime : currentTime).format(
          'YYYY-MM-DD HH:mm:ss'
        )
      })
      this.addUserform.setFieldsValue({
        listDate: moment(val.listDate ? val.listDate : currentTime).format(
          'YYYY-MM-DD HH:mm:ss'
        )
      })
      this.addUserform.setFieldsValue({
        subscribeTime: moment(val.subscribeTime ? val.subscribeTime : currentTime).format('YYYY-MM-DD HH:mm:ss')
      })
      // this.subscribeTime = moment(val.subscribeTime).format('YYYY-MM-DD HH:mm:ss')
      // this.subscriptionTime  = moment(val.subscriptionTime).format('YYYY-MM-DD HH:mm:ss')
    },
    CanceladdUserdialog () {
      this.addUserdialog = false
      const form = this.$refs.addUserform.form
      form.resetFields()
    },
    OkaddUserdialog () {
      const form = this.$refs.addUserform.form
      form.validateFields((errors, values) => {
        if (!errors) {
          if (this.currentdetail != '') {
            this.addUserDialogloading = true
            values.newlistId = this.currentdetail.newlistId
            values.subscriptionTime = this.subscriptionTime
            values.listDate = this.listDate
            values.subscribeTime = this.subscribeTime
            subscribeupdate(values).then((res) => {
              if (res.status == 0) {
                this.addUserdialog = false
                this.$message.success(res.msg)
                form.resetFields()
                this.getlist()
              } else {
                this.$message.error(res.msg)
              }
              this.addUserDialogloading = false
            })
          } else {
            this.addUserDialogloading = true
            values.subscriptionTime = this.subscriptionTime
            values.listDate = this.listDate
            values.subscribeTime = this.subscribeTime
            subscribeadd(values).then((res) => {
              if (res.status == 0) {
                this.addUserdialog = false
                this.$message.success(res.msg)
                form.resetFields()
                this.getinit()
              } else {
                this.$message.error(res.msg)
              }
              this.addUserDialogloading = false
            })
          }
        }
      })
    },
    getqueryParam () {
      this.queryParam = {
        pageNum: 1,
        pageSize: 10,
        code: '',
        name: '',
        zt: undefined,
        type: undefined
      }
    },
    getinit () {
      this.getqueryParam()
      this.pagination.current = 1
      this.getlist()
    },
    getlist () {
      this.loading = true
      subscribelist(this.queryParam).then((res) => {
        this.datalist = res.data.list
        this.pagination.total = res.data.total
        this.loading = false
      })
    },
    onPageChange (page, pageSize) {
      this.queryParam.pageNum = page
      this.pagination.current = page
      this.getlist()
    },
    onSizeChange (current, pageSize) {
      this.queryParam.pageNum = current
      this.pagination.current = page
      this.queryParam.pageSize = pageSize
      this.getlist()
    }
  }
}
</script>