out-order-add-model.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="title"
  5. :center="true"
  6. align="left"
  7. top="8vh"
  8. width="900px"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. element-loading-text="拼命加载中"
  12. element-loading-spinner="el-icon-loading"
  13. element-loading-background="rgba(0, 0, 0, 0.8)"
  14. @close="closeModel"
  15. >
  16. <el-card style="margin-top: -20px" class="account">
  17. <el-row :gutter="10">
  18. <el-col :span="24" style="margin: -15px 0 0 0">
  19. <el-divider>选择销售仓库</el-divider>
  20. </el-col>
  21. <el-col :span="24">
  22. <el-table
  23. ref="multipleTable"
  24. :data="tableData"
  25. border
  26. :size="'mini'"
  27. tooltip-effect="dark"
  28. style="width: 100%"
  29. @selection-change="handleSelectionChange($event, 0)"
  30. >
  31. <el-table-column type="selection" width="40" align="center" />
  32. <el-table-column
  33. prop="wsm_supplier"
  34. label="发货仓库"
  35. show-overflow-tooltip
  36. >
  37. <template slot-scope="scope">
  38. {{ scope.row.wsm_supplier }}/{{ scope.row.wsm_name }}
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="num" label="总下单数量" width="110" />
  42. <el-table-column prop="send_num" label="已发货数量" width="110" />
  43. <el-table-column prop="wsend_num" label="未发货数量" width="110" />
  44. <el-table-column prop="sale_price" label="销售价" width="110" />
  45. </el-table>
  46. </el-col>
  47. <el-col :span="24">
  48. <el-divider>选择收货地址</el-divider>
  49. </el-col>
  50. <el-col :span="24">
  51. <el-table
  52. ref="multipleTable"
  53. :data="tableData1"
  54. border
  55. :size="'mini'"
  56. tooltip-effect="dark"
  57. style="width: 100%"
  58. @selection-change="handleSelectionChange($event, 1)"
  59. >
  60. <el-table-column type="selection" width="40" align="center" />
  61. <el-table-column
  62. prop="receipt_quantity"
  63. label="总数量"
  64. width="100"
  65. />
  66. <el-table-column prop="send_num" label="已发货数量" width="100" />
  67. <el-table-column prop="wsend_num" label="未发货数量" width="100" />
  68. <el-table-column
  69. prop="arrive_time"
  70. label="最晚到货时间"
  71. width="145"
  72. />
  73. <el-table-column prop="contactor" label="收件人" width="60" />
  74. <el-table-column prop="mobile" label="联系电话" width="105" />
  75. <el-table-column
  76. prop="contactor"
  77. label="收件地址"
  78. show-overflow-tooltip
  79. >
  80. <template slot-scope="scope">
  81. {{ scope.row.addr_info }}{{ scope.row.addr }}
  82. </template>
  83. </el-table-column>
  84. <!-- <el-table-column prop="post_fee" label="物流费" width="100" /> -->
  85. </el-table>
  86. </el-col>
  87. <el-form
  88. ref="ruleForm"
  89. :model="ruleForm"
  90. status-icon
  91. :rules="rulesThis"
  92. label-width="90px"
  93. class="demo-ruleForm"
  94. >
  95. <el-row>
  96. <el-col :span="12">
  97. <el-form-item label="发货数量" prop="send_num">
  98. <el-input v-model="ruleForm.send_num" />
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="12">
  102. <el-form-item label="物流费用" prop="post_fee">
  103. <el-input v-model="ruleForm.post_fee" />
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="12">
  107. <el-form-item label="物流公司" prop="post_name">
  108. <!-- <el-input v-model="ruleForm.post_name" /> -->
  109. <search-express
  110. :value="ruleForm.post_name"
  111. :placeholder="'请输入物流公司'"
  112. :names="''"
  113. :disabled="false"
  114. :is-detail="false"
  115. @searchChange="handleCompany"
  116. />
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="12">
  120. <el-form-item label="物流单号" prop="post_code">
  121. <el-input v-model="ruleForm.post_code" />
  122. </el-form-item>
  123. </el-col>
  124. </el-row>
  125. <el-col :span="24" style="text-align: right">
  126. <el-button type="primary" @click="submitForm">保 存 </el-button>
  127. <el-button @click="closeModel">关 闭</el-button>
  128. </el-col>
  129. </el-form>
  130. </el-row>
  131. </el-card>
  132. </el-dialog>
  133. </template>
  134. <script>
  135. import asyncRequest from "@/apis/service/sellOut/salesOrder/detail";
  136. import resToken from "@/mixins/resToken";
  137. import { isnumber, isnumber2, isAlphanumeric } from "@/utils/validate";
  138. export default {
  139. name: "Account",
  140. props: ["showModel", "id", "sitem"],
  141. mixins: [resToken],
  142. data() {
  143. const validatePrice = (rule, value, callback) => {
  144. if (value === "") {
  145. callback(new Error("不能为空!"));
  146. } else {
  147. if (isnumber2(value)) {
  148. callback();
  149. } else {
  150. callback(new Error("仅支持整数或两位小数!"));
  151. }
  152. }
  153. };
  154. const validateWeight = (rule, value, callback) => {
  155. if (value === "") {
  156. callback(new Error("不能为空!"));
  157. } else {
  158. if (!isnumber(value)) {
  159. callback(new Error("仅支持整数!"));
  160. } else {
  161. callback();
  162. }
  163. }
  164. };
  165. const validateCode = (rule, value, callback) => {
  166. if (value === "") {
  167. callback(new Error("不能为空!"));
  168. } else {
  169. if (!isAlphanumeric(value)) {
  170. callback(new Error("仅支持字母和数字!"));
  171. } else {
  172. callback();
  173. }
  174. }
  175. };
  176. return {
  177. roleList: [],
  178. tableData: [],
  179. tableData1: [],
  180. loading: false,
  181. title: "新建销售出库单",
  182. list1: [],
  183. list0: [],
  184. showModelThis: this.showModel,
  185. rulesThis: {},
  186. rules: {
  187. send_num: {
  188. required: true,
  189. validator: validateWeight,
  190. trigger: "blur",
  191. },
  192. post_name: {
  193. type: "array",
  194. required: true,
  195. trigger: "change",
  196. message: "请输入物流公司",
  197. },
  198. post_code: {
  199. required: true,
  200. validator: validateCode,
  201. trigger: "blur",
  202. },
  203. post_fee: {
  204. required: true,
  205. validator: validatePrice,
  206. trigger: "blur",
  207. },
  208. },
  209. supplierName: "",
  210. good_price: "0",
  211. lasttime: "",
  212. ruleForm: {
  213. post_name: [], //裸价
  214. post_code: "", //仓库
  215. post_fee: "", //供应商
  216. send_num: "", //采购供应商编码
  217. addrid: "",
  218. orderCode: "",
  219. wsm_code: "",
  220. },
  221. };
  222. },
  223. watch: {
  224. showModel: function (val) {
  225. this.showModelThis = val;
  226. if (val) {
  227. this.initForm();
  228. }
  229. },
  230. showModelThis(val) {
  231. if (!val) {
  232. this.$emit("cancel");
  233. }
  234. },
  235. },
  236. methods: {
  237. closeModel() {
  238. console.log("closeModel!!");
  239. this.showModelThis = false;
  240. this.$emit("closeModel");
  241. },
  242. handleSelectionChange(e, type) {
  243. if (type === 0) {
  244. this.list0 = e;
  245. this.ruleForm.wsm_code = e && e.length > 0 ? e[0].wsm_code : "";
  246. } else {
  247. this.list1 = e;
  248. this.ruleForm.addrid = e && e.length > 0 ? e[0].id : "";
  249. }
  250. },
  251. async initForm() {
  252. this.loading = true;
  253. this.list0 = [];
  254. this.list1 = [];
  255. this.rulesThis = this.rules;
  256. await this.resetForm();
  257. this.loading = false;
  258. },
  259. //初始化表单
  260. async resetForm() {
  261. await this.$nextTick(() => {
  262. if (this.$refs.ruleForm) {
  263. this.$refs.ruleForm.resetFields();
  264. this.$refs.ruleForm.clearValidate();
  265. const { addrs, info, orderCode } = this.sitem;
  266. this.tableData = info;
  267. this.tableData1 = addrs;
  268. this.ruleForm = {
  269. post_name: [],
  270. post_code: "xxx2322",
  271. post_fee: "20",
  272. send_num: "10",
  273. addrid: "",
  274. orderCode: orderCode || "",
  275. wsm_code: "",
  276. };
  277. }
  278. });
  279. },
  280. // 保存更改
  281. async submitForm() {
  282. await this.$refs.ruleForm.validate(async (valid) => {
  283. if (valid) {
  284. const item = JSON.parse(JSON.stringify(this.ruleForm));
  285. if (this.list0.length === 0) {
  286. this.$message.warning("请选择发货仓库!");
  287. return;
  288. }
  289. if (this.list1.length === 0) {
  290. this.$message.warning("请选择收货地址!");
  291. return;
  292. }
  293. if (this.list0.length !== 1) {
  294. this.$message.warning("只能选择一个发货仓库!");
  295. return;
  296. }
  297. if (this.list1.length !== 1) {
  298. this.$message.warning("只能选择一个收货地址!");
  299. return;
  300. }
  301. let cNum = parseInt(this.list0[0].wsend_num);
  302. let aNum = parseInt(this.list1[0].wsend_num);
  303. let num = parseInt(this.ruleForm.send_num);
  304. if (num > cNum) {
  305. this.$message.warning("发货数量不能大于仓库未发货数量!");
  306. return;
  307. }
  308. if (num > aNum) {
  309. this.$message.warning("发货数量不能大于收货地址未发货数量!");
  310. return;
  311. }
  312. this.loading = true;
  313. item.post_name = item.post_name.toString();
  314. const res = await asyncRequest.saleout(item);
  315. this.loading = false;
  316. if (res && res.code === 0) {
  317. this.$notify.success({
  318. title: "添加成功",
  319. message: "",
  320. });
  321. this.showModelThis = false;
  322. this.$emit("refresh"); //抛出事件给详情页。
  323. } else if (res && res.code >= 100 && res.code <= 104) {
  324. await this.logout();
  325. } else {
  326. this.$message.warning(res.message);
  327. }
  328. } else {
  329. console.log("error submit!!");
  330. return false;
  331. }
  332. });
  333. },
  334. handleCompany(e) {
  335. console.log(e);
  336. if (e && e.code) {
  337. this.ruleForm.post_name = [e.shortName];
  338. }
  339. this.$refs.ruleForm.validateField("post_name");
  340. },
  341. },
  342. };
  343. </script>
  344. <style lang="scss" scoped>
  345. .account {
  346. .gongshi {
  347. span {
  348. vertical-align: top;
  349. display: inline-block;
  350. color: #000;
  351. }
  352. .icon-span {
  353. padding: 0 5px;
  354. height: 40px;
  355. line-height: 40px;
  356. font-size: 20px;
  357. color: #606266;
  358. display: inline-block;
  359. // vertical-align: top;
  360. // display: inline-block;
  361. }
  362. .label {
  363. height: 40px;
  364. line-height: 40px;
  365. }
  366. .tuan {
  367. &.chu {
  368. width: 60px;
  369. height: 40px;
  370. display: inline-block;
  371. span {
  372. width: 60px;
  373. display: inline-block;
  374. line-height: 20px;
  375. text-align: center;
  376. font-size: 12px;
  377. height: 20px;
  378. &:last-child {
  379. border-top: 1px solid #606266;
  380. }
  381. }
  382. }
  383. &.cheng {
  384. .name {
  385. height: 40px;
  386. line-height: 40px;
  387. }
  388. .icon-span {
  389. line-height: 40px;
  390. font-size: 16px;
  391. padding: 0 1px;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. </style>