out-order-add-model.vue 11 KB

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