| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <el-card shadow="never" style="border: 0;">
- <el-form ref="form" :model="form" label-width="80px" border stripe>
- <el-form-item label="客户名称">
- <el-select v-model="value" placeholder="请选择" @change="changeCustomer">
- <el-option
- v-for="item in customerList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="品种">
- <el-checkbox-group v-model="form.nameValue">
- <el-checkbox :label="item.label" :value="JSON.stringify(item)" v-for="(item, index) in options"
- :key="index" @change="changeType">
- </el-checkbox>
- </el-checkbox-group>
- </el-form-item>
- <el-form-item label="规格">
- <el-table :data="tableData" style="border: 1px solid rgb(235, 235, 235); border-radius: 6px">
- <el-table-column prop="name" label="规格" width="200">
- </el-table-column>
- <el-table-column prop="price" label="发货价格" align="center">
- <template #default="{row}">
- <el-input v-model="row.price" placeholder="发货价格"></el-input>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="120" header-align="right">
- <template #default="scope">
- <el-button @click.native.prevent="deleteRow(scope.$index, tableData)" type="text"
- size="small">
- 移除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="onSubmit">立即创建</el-button>
- <el-button>取消</el-button>
- </el-form-item>
- </el-form>
- </el-card>
- </template>
- <script>
- import form from "@components/Form.js";
- var typeList = [], boxList = [], customerList = [], customer = 0;
- export default {
- components: { 'YunForm': form },
- data() {
- return {
- row: Yunqi.data.row,
- tableData: [],
- value: "",
- form: {
- nameValue: [],
- },
- options: typeList,
- customerList: customerList,
- }
- },
- methods: {
- //获取客户
- changeCustomer: function (data) {
- customer =data
- },
- //获取规格
- changeType: function (data, row) {
- let obj = JSON.parse(row.target.value);
- //品种去重
- let idx = boxList.findIndex(item => item.value == obj.value);
- if (idx != -1) {
- boxList.splice(idx, 1)
- }else{
- boxList.push({ label: obj.label, value: obj.value });
- }
- Yunqi.ajax.get('shop/customer_spec/get_box', { type_id: obj.value }, false, false, true).then(res => {
- //编辑数据
- if (res.length > 0) {
- for (var key in Object(res)) {
- let index = this.tableData.findIndex(item => item.value == res[key]['id']);
- if (index != -1) {
-
- this.tableData.splice(index, 1)
- } else {
-
- this.tableData.push({ name: res[key]['title'], value: res[key]['id'], price: res[key]['price'], type_id:obj.value, type_name: obj.label });
- }
- }
- }
- });
- },
- onSubmit() {
- //获取规格
- if (this.tableData == "" || boxList.length == 0 || customer=="") return;
- Yunqi.ajax.post('shop/customer_spec/add', {customer_id: customer, type_list: boxList, type_box: this.tableData }, false, false, true).then(res => {
- if (res.code == 200) {
- this.$message.success(__('设置成功'));
- Yunqi.api.closelayer(Yunqi.app.window.id, true);
- } else {
- this.$message.error(res.msg);
- return false;
- }
- });
- },
- deleteRow(index, rows) {
- rows.splice(index, 1);
- }
- },
- onLoad: function () {
-
- let type = Yunqi.data.fieldList;
- //全部品种
- for (var key in Object(type)) {
- typeList.push({ label: type[key], value: key });
- }
- //全部客户
- let customer = Yunqi.data.customerList;
- for (var key in Object(customer)) {
- customerList.push({ label: customer[key], value: key });
- }
-
- },
- }
- </script>
- <style>
- </style>
|