Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

AddWareHouse.vue 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <el-dialog
  3. title="新增仓库信息"
  4. :visible.sync="dialogVisible"
  5. width="30%"
  6. :before-close="closePop"
  7. >
  8. <div class="main_contain">
  9. <el-form
  10. :model="ruleForm"
  11. :rules="rules"
  12. :label-position="labelPosition"
  13. ref="ruleForm"
  14. label-width="100px"
  15. class="demo-ruleForm"
  16. >
  17. <el-form-item label="仓库编号">
  18. <span>{{storehouse_code}}</span>
  19. </el-form-item>
  20. <el-form-item label="仓库名称" prop="storehouse_name">
  21. <el-input v-model="ruleForm.storehouse_name"></el-input>
  22. </el-form-item>
  23. <el-form-item label="仓库地址" prop="address">
  24. <el-input type="textarea" v-model="ruleForm.address"></el-input>
  25. </el-form-item>
  26. <el-form-item label="状态" prop="status">
  27. <el-radio-group v-model="ruleForm.status">
  28. <el-radio :label="1" >启用</el-radio>
  29. <el-radio :label="0" >禁用</el-radio>
  30. </el-radio-group>
  31. </el-form-item>
  32. <el-form-item label="仓库管理员" ><!--prop="region">-->
  33. admin
  34. <!-- <el-select v-model="ruleForm.region" placeholder="请选择管理员">-->
  35. <!-- <el-option label="admin" value="0"></el-option>-->
  36. <!-- </el-select>-->
  37. </el-form-item>
  38. </el-form>
  39. </div>
  40. <span slot="footer" class="dialog-footer">
  41. <el-button @click="closePop">取 消</el-button>
  42. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  43. </span>
  44. </el-dialog>
  45. </template>
  46. <script>
  47. import { getcode,addstorehouse,updatestorehouse } from "@/api/warehouse";
  48. import login from '../../../../mock/login'
  49. export default {
  50. data() {
  51. return {
  52. show_type: 1,
  53. storehouse_id: "",
  54. storehouse_code:"coco",
  55. dialogVisible: false,
  56. labelPosition:'left',
  57. ruleForm: {
  58. admin_name:"",
  59. storehouse_name: "",
  60. region: "",
  61. date1: "",
  62. date2: "",
  63. delivery: false,
  64. type: [],
  65. status: "",
  66. address: "",
  67. },
  68. //表单验证规则
  69. rules: {
  70. storehouse_name:[{
  71. required:true,message:"仓库名称不能为空",trigger: "change"
  72. }],
  73. address:[{
  74. required:true,message:"仓库地址不能为空",trigger: "change"
  75. }],
  76. // region: [{ required: true, message: "请选择活动区域", trigger: "change" }],
  77. type: [{
  78. type: "array",
  79. required: true,
  80. message: "请至少选择一个活动性质",
  81. trigger: "change",
  82. },],
  83. desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
  84. },
  85. type:"",
  86. // storehouse:{
  87. // storehouse_code:"",
  88. // },
  89. };
  90. },
  91. methods: {
  92. show(data, type) {
  93. if (type == 1) {
  94. this.initstorehouseData();
  95. this.show_type = 1;
  96. this.title = "新增仓库";
  97. this.dialogVisible = true;
  98. } else if (type == 2) {
  99. console.log("data:::::::::::",data);
  100. this.show_type = 2;
  101. this.storehouse_id = data.id;
  102. this.title = "编辑仓库";
  103. this.storehouse_code = data.storehouse_code;
  104. this.ruleForm.address = data.storehouse_address;
  105. this.ruleForm.status = data.storehouse_status;
  106. this.ruleForm.storehouse_name = data.storehouse_name;
  107. this.ruleForm.admin_name = data.storehouse_admin_name;
  108. console.log("this.ruleForm.admin_name",this.ruleForm.admin_name);
  109. this.dialogVisible = true;
  110. }
  111. },
  112. // 获取仓库编码接口
  113. initstorehouseData() {
  114. getcode().then((res) => {
  115. if (res.data.state == 1) {
  116. this.storehouse_code =
  117. res.data.data.list;
  118. }
  119. });
  120. },
  121. //清除表单数据
  122. closePop() {
  123. console.log("this.ruleForm",this.ruleForm)
  124. this.dialogVisible = false;
  125. this.ruleForm.storehouse_name = "";
  126. this.ruleForm.region = "";
  127. this.ruleForm.date1 = "";
  128. this.ruleForm.date2 = "";
  129. this.ruleForm.type = [];
  130. this.ruleForm.status = "";
  131. this.ruleForm.address = "";
  132. },
  133. // 验证表单内容
  134. submitForm(ruleForm) {
  135. if (this.show_type == 1) {
  136. this.$refs[ruleForm].validate((valid) => {
  137. if (valid) {
  138. console.log("this.ruleForm.status",this.ruleForm.status);
  139. let params = {
  140. storehouse_code: this.storehouse_code || "",
  141. storehouse_name: this.ruleForm.storehouse_name || "",
  142. storehouse_address: this.ruleForm.address || "",
  143. storehouse_status:parseInt(this.ruleForm.status)
  144. // storehouse_admin_id: this.ruleForm.storehouse_admin_id || "",
  145. // storehouse_admin_name: this.ruleForm.storehouse_admin_name || "",
  146. };
  147. console.log("params::::",params)
  148. console.log("status::::",this.ruleForm.status)
  149. addstorehouse(params).then((res) => {
  150. if (res.data.state == 1) {
  151. this.$message.success("新增成功");
  152. this.closePop();
  153. this.$emit("init");
  154. } else {
  155. this.$message.error("新增失败:" + res.data.msg);
  156. setTimeout(() => {
  157. this.closePop();
  158. }, 2000);
  159. }
  160. });
  161. } else {
  162. return false;
  163. }
  164. });
  165. } else if (this.show_type == 2) {
  166. this.$refs[ruleForm].validate((valid) => {
  167. if (valid) {
  168. console.log("this.ruleForm.status",this.ruleForm.status);
  169. let params = {
  170. storehouse_code: this.storehouse_code || "",
  171. storehouse_name: this.ruleForm.storehouse_name || "",
  172. storehouse_address: this.ruleForm.address || "",
  173. storehouse_status:parseInt(this.ruleForm.status),
  174. id: this.storehouse_id
  175. // storehouse_admin_id: this.ruleForm.storehouse_admin_id || "",
  176. // storehouse_admin_name: this.ruleForm.storehouse_admin_name || "",
  177. };
  178. updatestorehouse(params).then((res) => {
  179. if (res.data.state == 1) {
  180. this.$message.success("保存成功");
  181. this.closePop();
  182. this.$emit("init");
  183. } else {
  184. this.$message.error("保存失败:" + res.data.msg);
  185. setTimeout(() => {
  186. this.closePop();
  187. }, 2000);
  188. }
  189. });
  190. } else {
  191. return false;
  192. }
  193. });
  194. }
  195. this.contactsinfo();
  196. },
  197. },
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. .main_contain {
  202. width: 60%;
  203. display: flex;
  204. flex-direction: column;
  205. margin: 0 auto;
  206. .main_list {
  207. height: 30px;
  208. display: flex;
  209. line-height: 30px;
  210. }
  211. }
  212. </style>