大宝管理后台代码
ne1
zzzz
2024-04-07 69ff731fbacf2f2ae16f98a355506bfeb01dd567
src/views/product/shares.vue
@@ -55,13 +55,13 @@
            <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 = 1,getlist()">查询
                    @click=";(queryParam.pageNum = 1), (pagination.current = 1), getlist()"
                    >查询
                  </a-button>
                  <!-- <a-button
@@ -70,7 +70,6 @@
                    style="margin-left: 8px"
                    @click="addUserdialog = true">
                    添加股票</a-button> -->
                </span>
              </a-form-item>
            </a-col>
@@ -86,20 +85,33 @@
        :pagination="pagination"
        :columns="columns"
        :data-source="datalist"
        rowKey="id">
        rowKey="id"
      >
        <span slot="stockName" slot-scope="text,record">
          <template>
            <div>
              <span style="margin-right:10px">{{ record.stockName }}</span>
              <a-tag color="green">{{ record.stockCode }}
              </a-tag>
              <a-tag color="green">{{ record.stockCode }} </a-tag>
            </div>
          </template>
        </span>
        <span slot="stockType" slot-scope="text,record">
          <template>
            <div>
              <a-tag color="red">{{ record.stockType == 'sz' ? '深股' : record.stockType == 'sh' ? '沪股' : record.stockType == 'bj' ? '京股' : record.stockType == 'hk' ? '港股' : record.stockType == 'us' ? '美股' : '' }}
              <a-tag color="red"
                >{{
                  record.stockType == 'sz'
                    ? '深股'
                    : record.stockType == 'sh'
                    ? '沪股'
                    : record.stockType == 'bj'
                    ? '京股'
                    : record.stockType == 'hk'
                    ? '港股'
                    : record.stockType == 'us'
                    ? '美股'
                    : ''
                }}
              </a-tag>
            </div>
          </template>
@@ -107,9 +119,8 @@
        <span slot="nowPrice" slot-scope="text,record">
          <template>
            <div>
              <a-tag :color="record.hcrate < 0 ? 'green' : record.hcrate > 0 ? 'red' : ''">{{
                Number(record.nowPrice).toFixed(2)
              }}
              <a-tag :color="record.hcrate < 0 ? 'green' : record.hcrate > 0 ? 'red' : ''"
                >{{ Number(record.nowPrice).toFixed(2) }}
              </a-tag>
            </div>
          </template>
@@ -161,15 +172,12 @@
        </span>
        <template slot="action" slot-scope="text,record">
          <a slot="action" href="javascript:;" @click="getisShow(record.id, record.isShow)">{{ record.isShow
            ==
            0 ? '隐藏股票' :
              '显示股票'
          <a slot="action" href="javascript:;" @click="getisShow(record.id, record.isShow)">{{
            record.isShow == 0 ? '隐藏股票' : '显示股票'
          }}</a>
          <a-divider type="vertical" />
          <a slot="action" href="javascript:;" @click="getisLock(record.id, record.isLock)">{{ record.isLock
            == 0 ? '锁定股票' :
              '解锁股票'
          <a slot="action" href="javascript:;" @click="getisLock(record.id, record.isLock)">{{
            record.isLock == 0 ? '锁定股票' : '解锁股票'
          }}</a>
          <a-divider type="vertical" />
          <a slot="action" href="javascript:;" @click="geteditStock(record)">{{ '修改股票' }}</a>
@@ -183,22 +191,26 @@
      :visible="addUserdialog"
      :confirmLoading="addUserDialogloading"
      @ok="OkaddUserdialog"
      @cancel="CanceladdUserdialog">
      @cancel="CanceladdUserdialog"
    >
      <a-form :form="addUserform" ref="addUserform">
        <a-form-item label="股票名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入股票名称"
            v-decorator="['stockName', { rules: [{ required: true, message: '请输入股票名称', }] }]" />
            v-decorator="['stockName', { rules: [{ required: true, message: '请输入股票名称' }] }]"
          />
        </a-form-item>
        <a-form-item label="股票代码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入股票代码"
            v-decorator="['stockCode', { rules: [{ required: true, message: '请输入股票代码', }] }]" />
            v-decorator="['stockCode', { rules: [{ required: true, message: '请输入股票代码' }] }]"
          />
        </a-form-item>
        <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="sh">沪股</a-select-option>
            <a-select-option value="sz">深股</a-select-option>
            <a-select-option value="bj">京股</a-select-option>
@@ -209,7 +221,8 @@
        <a-form-item label="科创板股票" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select
            placeholder="请选择科创板股票"
            v-decorator="['stockPlate', { rules: [{ required: true, message: '请选择科创板股票', }] }]">
            v-decorator="['stockPlate', { rules: [{ required: true, message: '请选择科创板股票' }] }]"
          >
            <a-select-option value="A股">否</a-select-option>
            <a-select-option value="科创">是</a-select-option>
          </a-select>
@@ -217,7 +230,8 @@
        <a-form-item label="锁定状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select
            placeholder="请选择锁定状态"
            v-decorator="['isLock', { rules: [{ required: true, message: '请选择锁定状态', }] }]">
            v-decorator="['isLock', { rules: [{ required: true, message: '请选择锁定状态' }] }]"
          >
            <a-select-option value="0">未锁定</a-select-option>
            <a-select-option value="1">锁定</a-select-option>
          </a-select>
@@ -225,7 +239,8 @@
        <a-form-item label="显示状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select
            placeholder="请选择显示状态"
            v-decorator="['isShow', { rules: [{ required: true, message: '请选择显示状态', }] }]">
            v-decorator="['isShow', { rules: [{ required: true, message: '请选择显示状态' }] }]"
          >
            <a-select-option value="0">显示</a-select-option>
            <a-select-option value="1">不显示</a-select-option>
          </a-select>
@@ -239,17 +254,20 @@
      :visible="editStockdialog"
      :confirmLoading="editStockdialogloading"
      @ok="OkeditStockdialog"
      @cancel="CanceleditStockdialog">
      @cancel="CanceleditStockdialog"
    >
      <a-form :form="editStockform" ref="editStockform">
        <a-form-item label="股票名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入股票名称"
            v-decorator="['stockName', { rules: [{ required: true, message: '请输入股票名称', }] }]" />
            v-decorator="['stockName', { rules: [{ required: true, message: '请输入股票名称' }] }]"
          />
        </a-form-item>
        <a-form-item label="点差费率" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入点差费率"
            v-decorator="['spreadRate', { rules: [{ required: true, message: '请输入点差费率', }] }]" />
            v-decorator="['spreadRate', { rules: [{ required: true, message: '请输入点差费率' }] }]"
          />
        </a-form-item>
      </a-form>
    </a-modal>
@@ -268,7 +286,7 @@
                    title: '股票名称 / 股票代码',
                    dataIndex: 'stockName',
                    align: 'center',
                    scopedSlots: { customRender: 'stockName' }
          scopedSlots: { customRender: 'stockName' },
                },
                // {
                //     title: '沪深京股',
@@ -280,13 +298,13 @@
                    title: '现价',
                    dataIndex: 'nowPrice',
                    align: 'center',
                    scopedSlots: { customRender: 'nowPrice' }
          scopedSlots: { customRender: 'nowPrice' },
                },
                {
                    title: '涨跌幅',
                    dataIndex: 'hcrate',
                    align: 'center',
                    scopedSlots: { customRender: 'hcrate' }
          scopedSlots: { customRender: 'hcrate' },
                },
                // {
                //     title: '最近3天涨跌',
@@ -304,13 +322,13 @@
                    title: '显示状态',
                    dataIndex: 'isShow',
                    align: 'center',
                    scopedSlots: { customRender: 'isShow' }
          scopedSlots: { customRender: 'isShow' },
                },
                {
                    title: '股票状态',
                    dataIndex: 'isLock',
                    align: 'center',
                    scopedSlots: { customRender: 'isLock' }
          scopedSlots: { customRender: 'isLock' },
                },
                {
                    title: '添加时间',
@@ -318,14 +336,14 @@
                    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' }
                }
          scopedSlots: { customRender: 'action' },
        },
            ],
            // 表头
            pagination: {
@@ -336,7 +354,7 @@
                pageSizeOptions: ['10', '20', '50', '100'], // 每页中显示的数据
                onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize), // 改变每页数量时更新显示
                onChange: (page, pageSize) => this.onPageChange(page, pageSize), // 点击页码事件
                showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
        showTotal: (total) => `共有 ${total} 条数据`, // 分页中显示总的数据
            },
            loading: false,
            queryParam: {
@@ -347,16 +365,16 @@
                stockPlate: 'A股',
                stockType: undefined,
                showState: undefined,
                lockState: undefined
        lockState: undefined,
            },
            datalist: [],
            labelCol: {
                xs: { span: 24 },
                sm: { span: 7 }
        sm: { span: 7 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 13 }
        sm: { span: 13 },
            },
            addUserform: this.$form.createForm(this),
            addUserdialog: false,
@@ -366,7 +384,7 @@
            editStockdialogloading: false,
            editStockform: this.$form.createForm(this),
            fields: ['stockName', 'spreadRate'],
            currentid: ''
      currentid: '',
        }
    },
    created () {
@@ -376,7 +394,7 @@
        geteditStock (val) {
            this.currentid = val.id
            this.editStockdialog = true
            this.fields.forEach(v => this.editStockform.getFieldDecorator(v))
      this.fields.forEach((v) => this.editStockform.getFieldDecorator(v))
            this.editStockform.setFieldsValue(pick(val, this.fields))
        },
        CanceleditStockdialog () {
@@ -390,14 +408,14 @@
                if (!errors) {
                    this.editStockdialogloading = true
                    values.id = this.currentid
                    stockupdateStock(values).then(res => {
          stockupdateStock(values).then((res) => {
                        if (res.status == 0) {
                            this.editStockdialog = false
                            this.$message.success({ content: res.msg, duration: 2 })
              this.$message.success(res.msg)
                            form.resetFields()
                            this.getlist()
                        } else {
                            this.$message.error({ content: res.msg })
              this.$message.error(res.msg)
                        }
                        this.editStockdialogloading = false
                    })
@@ -416,15 +434,15 @@
            form.validateFields((errors, values) => {
                if (!errors) {
                    this.addUserDialogloading = true
                    values.stockPlate == 'A股' ? values.stockPlate = '' : values.stockPlate
                    stockadd(values).then(res => {
          values.stockPlate == 'A股' ? (values.stockPlate = '') : values.stockPlate
          stockadd(values).then((res) => {
                        if (res.status == 0) {
                            this.addUserdialog = false
                            this.$message.success({ content: res.msg, duration: 2 })
              this.$message.success(res.msg)
                            form.resetFields()
                            this.getinit()
                        } else {
                            this.$message.error({ content: res.msg })
              this.$message.error(res.msg)
                        }
                        this.addUserDialogloading = false
                    })
@@ -440,7 +458,7 @@
                stockPlate: 'A股',
                stockType: undefined,
                showState: undefined,
                lockState: undefined
        lockState: undefined,
            }
        },
        getinit () {
@@ -450,17 +468,17 @@
        },
        getlist () {
            this.loading = true
            this.queryParam.stockPlate == 'A股' ? this.queryParam.stockPlate = '' : this.queryParam.stockPlate
            stocklist(this.queryParam).then(res => {
      this.queryParam.stockPlate == 'A股' ? (this.queryParam.stockPlate = '') : this.queryParam.stockPlate
      stocklist(this.queryParam).then((res) => {
                this.datalist = res.data.list
                this.pagination.total = res.data.total
                this.queryParam.stockPlate == '' ? this.queryParam.stockPlate = 'A股' : this.queryParam.stockPlate
        this.queryParam.stockPlate == '' ? (this.queryParam.stockPlate = 'A股') : this.queryParam.stockPlate
                this.loading = false
            })
        },
        // 股票的显示隐藏
        getisShow (idval, isShowval) {
            updateShow({ stockId: idval }).then(res => {
      updateShow({ stockId: idval }).then((res) => {
                if (res.status === 0) {
                    this.getlist()
                    if (isShowval == 0) {
@@ -475,7 +493,7 @@
        },
        // 股票的锁定解锁
        getisLock (idval, isLockval) {
            updateLock({ stockId: idval }).then(res => {
      updateLock({ stockId: idval }).then((res) => {
                if (res.status === 0) {
                    this.getlist()
                    if (isLockval == 0) {
@@ -498,7 +516,7 @@
            this.pagination.current = page
            this.queryParam.pageSize = pageSize
            this.getlist()
        }
    }
    },
  },
}
</script>