123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783 |
- <template>
- <div class="addStore pagePadding">
- <div
- v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
- >
- 123{{}}
- <el-form
- ref="ruleForm"
- :model="ruleForm"
- status-icon
- :rules="rulesThis"
- label-width="100px"
- class="demo-ruleForm"
- v-if="addId === 'add'"
- >
- <el-divider content-position="center">仓库信息:</el-divider>
- <el-row>
- <el-col :span="12"
- ><el-form-item
- label="所属公司"
- prop="storeToCompany"
- style="width: 100%"
- >
- <search-supplier @searchCard="getCompanyName"></search-supplier>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="仓库名称" prop="accountName">
- <el-input
- placeholder="请输入仓库名称"
- filterable
- clearable
- v-model="ruleForm.accountName"
- @change="getValue1"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <!-- 省/市/区选择组件 -->
- <el-form-item label="省/市/区" prop="accountToArea">
- <select-area @areaSelect="areaSelect"></select-area>
- </el-form-item>
- </el-col>
- <el-col :span="12"
- ><!-- 仓库详细地址 -->
- <el-form-item label="详细地址" prop="accountDetail">
- <el-input
- placeholder="请输入内容"
- v-model="ruleForm.accountDetail"
- clearable
- @change="accountDetail"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="负责人" prop="accountDutyer" style="width: 100%">
- <search-account
- :size="searchSize"
- :code="accountNo"
- :placeholder="'请输入负责人'"
- :is-detail="true"
- :disabled="false"
- :names="accountNames"
- @change="accountChange"
- />
- </el-form-item></el-col
- >
- <el-col :span="12">
- <el-form-item label="负责人电话" prop="dutyer_mobile">
- <el-input
- type="number"
- placeholder="请输入联系人电话"
- v-model="ruleForm.dutyer_mobile"
- clearable
- >
- </el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-divider content-position="center">收发货信息:</el-divider>
- <!-- 收发货联系信息 -->
- <el-row>
- <el-col :span="12"
- ><!-- 收发货联系人 -->
- <el-form-item label="联系人" prop="linker">
- <el-input
- placeholder="请填写联系人"
- v-model="ruleForm.linker"
- clearable
- @change="linker"
- >
- </el-input> </el-form-item
- ></el-col>
- <el-col :span="12">
- <!-- 联系人电话 -->
- <el-form-item label="电话" prop="linker_mobile">
- <el-input
- type="number"
- placeholder="请输入联系人电话"
- v-model="ruleForm.linker_mobile"
- clearable
- @change="linkerMobile"
- >
- </el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <!-- 收发货地址 -->
- <el-form-item label="省/市/区" prop="linker_addr">
- <select-area @areaSelect="selectArea"/> </el-form-item
- ></el-col>
- <el-col :span="12">
- <!-- 收发货详细地址 -->
- <el-form-item label="详细地址" prop="linker_detail">
- <el-input
- placeholder="请输入详细地址"
- v-model="ruleForm.linker_detail"
- clearable
- @change="linkerDetail"
- >
- </el-input> </el-form-item
- ></el-col>
- </el-row>
- </el-form>
- <!-- 仓库详情 -->
- <el-form
- ref="ruleForm"
- :disabled="addId === 'detail'"
- :model="ruleForm"
- status-icon
- :rules="rulesThis"
- label-width="100px"
- class="demo-ruleForm"
- v-if="addId === 'detail'"
- >
- <el-divider content-position="center">仓库信息:</el-divider>
- <el-row>
- <el-col :span="12"
- ><el-form-item label="所属公司" prop="storeToCompany">
- <el-cascader
- placeholder="请选择所属公司"
- filterable
- clearable
- style="width: 100%"
- v-model="ruleForm.storeToCompany"
- :options="ruleForm.selectaccount_go_options"
- @change="getValue"
- ></el-cascader>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="仓库名称" prop="accountName">
- <el-input
- placeholder="请输入仓库名称"
- filterable
- clearable
- v-model="ruleForm.accountName"
- @change="getValue1"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <!-- 省/市/区选择组件 -->
- <el-form-item label="省/市/区" prop="accountToArea">
- <select-area @areaSelect="areaSelect"></select-area>
- </el-form-item>
- </el-col>
- <el-col :span="12"
- ><!-- 仓库详细地址 -->
- <el-form-item label="详细地址" prop="accountDetail">
- <el-input
- placeholder="请输入内容"
- v-model="ruleForm.accountDetail"
- clearable
- @change="accountDetail"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="负责人" prop="accountDutyer" style="width: 50%">
- <el-select
- style="width: 100%"
- v-model="ruleForm.accountDutyer"
- placeholder="请选择仓库负责人"
- >
- <el-option
- v-for="item in ruleForm.accountDutyer_options"
- :key="item.id"
- :label="item.nickname"
- :value="item.id"
- >
- {{ item }}
- <!-- <span style="float: left">{{ item.nickname }}</span>
- <span style="float: right; color: #8492a6; font-size: 13px">{{
- item.role_name
- }}</span> -->
- </el-option>
- </el-select>
- </el-form-item>
- <el-divider content-position="center">收发货信息:</el-divider>
- <!-- 收发货联系信息 -->
- <el-row>
- <el-col :span="12"
- ><!-- 收发货联系人 -->
- <el-form-item label="联系人" prop="linker">
- <el-input
- placeholder="请填写联系人"
- v-model="ruleForm.linker"
- clearable
- @change="linker"
- >
- </el-input> </el-form-item
- ></el-col>
- <el-col :span="12">
- <!-- 联系人电话 -->
- <el-form-item label="电话" prop="linker_mobile">
- <el-input
- type="number"
- placeholder="请输入联系人电话"
- v-model="ruleForm.linker_mobile"
- clearable
- @change="linkerMobile"
- >
- </el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <!-- 收发货地址 -->
- <el-form-item label="省/市/区" prop="linker_addr">
- <select-area @areaSelect="selectArea"></select-area> </el-form-item
- ></el-col>
- <el-col :span="12">
- <!-- 收发货详细地址 -->
- <el-form-item label="详细地址" prop="linker_detail">
- <el-input
- placeholder="请输入详细地址"
- v-model="ruleForm.linker_detail"
- clearable
- @change="linkerDetail"
- >
- </el-input> </el-form-item
- ></el-col>
- </el-row>
- </el-form>
- <el-col :span="24" style="text-align: right">
- <el-button
- v-if="addId === 'add'"
- type="primary"
- @click="submitForm('ruleForm')"
- >保 存
- </el-button>
- <el-button @click="showModelThis = false">{{
- isDetail ? "关 闭" : "取 消"
- }}</el-button>
- </el-col>
- </div>
- <div v-else>
- <no-auth></no-auth>
- </div>
- </div>
- </template>
- <script>
- import asyncRequest from "@/apis/service/purchaseIn/addStore";
- // import resToken from "@/mixins/resToken";
- import mixinPage from "@/mixins/elPaginationHandle";
- import resToken from "@/mixins/resToken";
- // import statusList from "@/assets/js/statusList";
- import addEdit from "./addEdit";
- import { mapGetters } from "vuex";
- import { isMobile } from "@/utils/validate";
- export default {
- name: "addStore",
- // props: ["showModel", "id", "isDetail", "sitem"],
- // mixins: [resToken],
- mixins: [mixinPage, resToken],
- components: {
- addEdit,
- },
- computed: {
- ...mapGetters(["tablebtnSize", "searchSize", "size"]),
- powers() {
- let tran =
- this.$store.getters.btnList.find(
- (item) => item.menu_route == "addStore"
- ) || {};
- if (tran && tran.action && tran.action.length > 0) {
- return tran.action;
- } else {
- return [];
- }
- },
- },
- data() {
- const validatemobile = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("手机号不能为空!"));
- } else {
- if (!isMobile(value)) {
- callback(new Error("手机号格式不正确!"));
- } else {
- callback();
- }
- }
- };
- return {
- stockNo: [""],
- stockNames: "",
- accountDutyer: "", //仓库负责人
- // addId: this.$route.query.id,
- addId: "",
- // route: this.$route,
- roleList: [],
- loading: false,
- title: "添加账号",
- organizeList: [],
- showModelThis: this.showModel,
- //省市区接口入参
- addr_code: {
- provice_code: "",
- city_code: "",
- area_code: "",
- },
- ruleForm: {
- storeToCompany: "",
- selectaccount_go: "", //公司
- accountName: "", //仓库名称
- accountDutyer: "", //仓库负责人
- dutyer_mobile: "",
- linker: "", //收发货联系人
- linker_mobile: "", //收发货人联系电话
- linker_detail: "",
- // linker_addr: [], //收发货地址
- // accountDutyer_options: [], //仓库负责人列表
- // accountDetail: [], //仓库详细地址
- // selectaccount_go_options: [], //公司列表
- // accountToArea: [],
- }, //
- rulesThis: this.rules,
- rules: {
- storeToCompany: [
- {
- // type: "array",
- required: true,
- message: "请选择仓库所在公司",
- trigger: "blur",
- // trigger: "change",
- },
- ],
- accountName: [
- {
- required: true,
- message: "请输入仓库名称",
- trigger: "blur",
- },
- ],
- accountDutyer: [
- {
- // type: "array",
- required: true,
- message: "请选择仓库负责人",
- // trigger: "change",
- trigger: "blur",
- },
- ],
- accountToArea: [
- {
- type: "array",
- required: true,
- message: "请选择仓库所在地址",
- trigger: "change",
- },
- ],
- accountDetail: [
- {
- required: true,
- message: "请选择仓库详细地址",
- trigger: "blur",
- },
- ],
- linker: [
- {
- required: true,
- message: "请填写收发货联系人",
- trigger: "blur",
- },
- ],
- linker_mobile: [
- {
- required: true,
- trigger: "blur",
- validator: validatemobile,
- },
- ],
- dutyer_mobile: [
- {
- required: true,
- trigger: "blur",
- validator: validatemobile,
- },
- ],
- linker_addr: [
- {
- type: "array",
- required: true,
- message: "请填写收发货联系人地址",
- trigger: "change",
- },
- ],
- linker_detail: [
- {
- required: true,
- message: "请输入详细地址",
- trigger: "blur",
- },
- ],
- },
- parmValue: {
- //入参
- name: "", //仓库名称
- supplierNo: "", //供应商编码
- wsmtype: 1, //仓库类型
- addr: "", //仓库地址
- contactor: "", //仓库联系人
- mobile: "", //仓库联系方式
- position: "", //联系人职位
- wsm_name: "", // 收发货联系人
- wsm_mobile: "", //收发货联系方式
- addr_code: {
- provice_code: "",
- city_code: "",
- area_code: "",
- },
- wsm_addr: "", //地址详细
- },
- };
- },
- watch: {
- $route: function (val, old) {
- this.addId = val.query.id;
- },
- },
- mounted() {
- this.addId = this.$route.query.id;
- this.getCompany();
- this.initForm();
- },
- methods: {
- stockChange(e) {
- console.log(e);
- },
- // 获取公司列表
- getCompanyName(val) {
- this.ruleForm.storeToCompany = val[1];
- console.log(this.ruleForm.storeToCompany);
- },
- // 联系人电话
- linkerMobile(val) {
- this.parmValue.wsm_mobile = val;
- },
- // 联系人
- linker(val) {
- this.parmValue.wsm_name = val;
- },
- // 仓库详细地址
- accountDetail(val) {
- console.log(val);
- this.parmValue.addr = val;
- },
- //仓库地址选择
- areaSelect(val) {
- console.log(val);
- this.ruleForm.accountToArea = val;
- this.parmValue.addr = val;
- },
- // 收发货地址选择
- selectArea(val) {
- this.parmValue.addr_code.provice_code = val[0];
- this.parmValue.addr_code.city_code = val[1];
- this.parmValue.addr_code.area_code = val[2];
- this.ruleForm.linker_addr = val;
- },
- // 收发货详细地址
- linkerDetail(val) {
- this.parmValue.wsm_addr = val;
- },
- // 仓库所在公司
- getValue(val) {
- this.parmValue.supplierNo = val;
- },
- // 仓库名
- getValue1(val) {
- this.parmValue.name = val;
- },
- // 负责人
- getValue2(val) {
- console.log(val);
- this.accountDutyer = val;
- },
- closeModel() {
- console.log("closeModel!!");
- },
- async initForm() {
- this.loading = true;
- // await this.getClist();
- // await this.getRole();
- this.ruleForm = {
- accountName: "my-account", //仓库名称
- accountDutyer: "", //仓库负责人
- linker: "", //收发货联系人
- linker_mobile: "", //收发货人联系电话
- linker_addr: "", //收发货地址
- selectaccount_go_options: [],
- accountDutyer_options: [],
- };
- console.log(this.addId);
- if (this.addId === "add") {
- console.log("新建仓库节点");
- console.log(this.ruleForm);
- this.rulesThis = this.rules;
- await this.resetForm();
- } else if (this.addId === "detail") {
- console.log("detail");
- this.rulesThis = {};
- await this.resetForm(this.sitem);
- // await this.initData()
- } else {
- console.log("当前是编辑按钮");
- this.rulesThis = this.rules;
- }
- this.loading = false;
- },
- async getClist() {
- this.organizeList = [];
- const res = await asyncRequest.getClist({});
- if (res && res.code === 0 && res.data) {
- this.organizeList = res.data;
- this.recursion(this.organizeList);
- }
- },
- recursion(list) {
- list.map((v) => {
- if (v && Array.isArray(v.child)) {
- v.value = v.id + "";
- v.label = v.name;
- if (v.child.length === 0) {
- delete v["child"];
- } else {
- this.recursion(v.child);
- }
- }
- return v;
- });
- },
- async getRole() {
- const model = {
- status: "", // 状态
- level: "", // 姓名
- role_name: "",
- };
- const res = await asyncRequest.getRole(model);
- if (res && res.code === 0 && res.data) {
- this.roleList = res.data;
- this.roleList.map((v1) => {
- v1.id += "";
- v1.status += "";
- return v1;
- });
- }
- },
- async resetForm(sitem) {
- // 重置
- await this.$nextTick(() => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- this.ruleForm = {
- dutyer_mobile: "18818818818",
- accountDetail: "顺义区宏远888",
- selectaccount_go: "", //出库仓库
- selectaccount_go_options: [], //出库仓库列表
- accountName: "my-account", //仓库名称
- linker: "张三",
- linker_mobile: "13223289230",
- linker_detail: "朝阳区太阳城666",
- accountDutyer: "", //仓库负责人
- accountDutyer_options: [], //仓库负责人列表
- };
- if (this.id === "add" || this.isDetail) {
- this.rules.username[0].required = false;
- }
- }
- });
- },
- async submitForm(formName) {
- let paraValue = {
- name: this.ruleForm.accountName,
- supplierNo: this.ruleForm.storeToCompany,
- wsmtype: "1", //仓库类型
- addr: this.ruleForm.accountDetail, //仓库地址
- contactor: this.accountDutyer, //仓库联系人职位
- mobile: this.ruleForm.dutyer_mobile, //仓库联系人
- position: "采购",
- // wsm_type:"",后台暂时不用
- wsm_name: this.ruleForm.linker,
- wsm_mobile: this.ruleForm.linker_mobile,
- addr_code: {
- // provice_code: this.ruleForm.linker_addr[0],
- // city_code: this.ruleForm.linker_addr[1],
- // area_code: this.ruleForm.linker_addr[2],
- },
- wsm_addr: this.ruleForm.linker_detail,
- addrs_code: {
- // provice_code: this.ruleForm.accountToArea[0],
- // city_code: this.ruleForm.accountToArea[1],
- // area_code: this.ruleForm.accountToArea[2],
- },
- };
- console.log(paraValue);
- console.log(this.ruleForm);
- this.$refs[formName].validate((valid) => {
- console.log(valid);
- if (valid) {
- console.log("submit!");
- this.getList(paraValue);
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- // 表单提交
- async getList(paraValue) {
- const res = await asyncRequest.add(paraValue);
- if (res && res.code === 0 && res.data) {
- console.log(res.data);
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- }
- this.loading = false;
- },
- async getDutyer() {
- this.loading = true;
- const obj = {
- name: "",
- page: 1,
- size: 15,
- status: "",
- username: "",
- };
- const res = await asyncRequest.getlist(obj);
- if (res && res.code === 0 && res.data) {
- const { list } = res.data;
- this.ruleForm.accountDutyer_options = list;
- console.log(this.ruleForm.accountDutyer_options);
- // console.log(res.data.list);
- // res.data.list.forEach((element) => {
- // // let dutyer = {
- // // label: element.nickname,
- // // value: element.depart[0] ? element.depart[0].name : "",
- // // };
- // // console.log(this.ruleForm.accountDutyer_options);
- // this.ruleForm.accountDutyer_options.push(element);
- // });
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- this.tableData = [];
- this.pageInfo.total = 0;
- }
- this.loading = false;
- },
- async getCompany() {
- this.loading = true;
- const obj = {
- page: 1,
- size: 15,
- };
- const res = await asyncRequest.getCompany(obj);
- if (res && res.code === 0 && res.data) {
- console.log(res.data.list);
- res.data.list.forEach((element) => {
- let company = {
- label: element.name,
- value: element.code,
- };
- // console.log(this.ruleForm.selectaccount_go_options);
- this.ruleForm.selectaccount_go_options.push(company);
- // this.ruleForm.accountDutyer_options.push(dutyer);
- });
- // console.log(this.ruleForm.selectaccount_go_options);
- // this.tableData = res.data.list;
- // this.pageInfo.total = Number(res.data.count);
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- this.tableData = [];
- this.pageInfo.total = 0;
- }
- this.getDutyer();
- this.loading = false;
- },
- // 新建仓库
- async addaccount() {
- this.loading = true;
- console.log(this.parmValue);
- const res = await asyncRequest.addaccount(this.parmValue);
- if (res && res.code === 0 && res.data) {
- console.log(res.data.list);
- res.data.list.forEach((element) => {
- // console.log(element.nickname);
- let company = {
- label: element.name,
- value: element.code,
- };
- this.ruleForm.selectaccount_go_options.push(company);
- // this.ruleForm.accountDutyer_options.push(dutyer);
- });
- console.log(this.ruleForm.selectaccount_go_options);
- // this.tableData = res.data.list;
- // this.pageInfo.total = Number(res.data.count);
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- // this.tableData = [];
- // this.pageInfo.total = 0;
- }
- this.loading = false;
- },
- // 获取仓库详情
- async getStocDetail() {
- this.loading = true;
- // console.log(this.parmValue);
- const res = await asyncRequest.detail(5);
- if (res && res.code === 0 && res.data) {
- console.log(res.data.list);
- res.data.list.forEach((element) => {
- // console.log(element.nickname);
- let company = {
- label: element.name,
- value: element.code,
- };
- this.ruleForm.selectaccount_go_options.push(company);
- // this.ruleForm.accountDutyer_options.push(dutyer);
- });
- console.log(this.ruleForm.selectaccount_go_options);
- // this.tableData = res.data.list;
- // this.pageInfo.total = Number(res.data.count);
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- // this.tableData = [];
- // this.pageInfo.total = 0;
- }
- this.loading = false;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- </style>
|