purchase-order-addedit-model.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="title"
  5. :center="true"
  6. align="left"
  7. top="10vh"
  8. width="1040px"
  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">
  19. <el-form
  20. :model="ruleForm"
  21. :rules="rules"
  22. status-icon
  23. ref="ruleForm"
  24. label-width="110px"
  25. class="demo-ruleForm"
  26. >
  27. <el-row>
  28. <el-row>
  29. <el-col :span="12">
  30. <el-form-item label="采购供应商" prop="supplierNo">
  31. <search-supplier
  32. :disabled="isDisabled"
  33. :value="ruleForm.supplierNo"
  34. :placeholder="'请选择供应商'"
  35. :is-detail="true"
  36. :names="supplierName"
  37. @searchChange="selectSupplier"
  38. />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="12">
  42. <el-form-item label="预计入库时间" prop="expecttime">
  43. <el-date-picker
  44. :disabled="isDisabled"
  45. v-model="ruleForm.expecttime"
  46. type="datetime"
  47. style="width: 100%"
  48. value-format="yyyy-MM-dd HH:mm:ss"
  49. placeholder="选择日期"
  50. :picker-options="pickerOptions"
  51. @change="selectTime"
  52. >
  53. </el-date-picker>
  54. </el-form-item>
  55. </el-col>
  56. </el-row>
  57. <el-row>
  58. <el-col :span="8">
  59. <el-form-item label="实时金价" prop="now_god_price">
  60. <el-input
  61. placeholder="0"
  62. disabled
  63. v-model="ruleForm.now_god_price"
  64. maxlength="100"
  65. >
  66. <template slot="append">元</template>
  67. </el-input>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="8">
  71. <el-form-item label="采购数量" prop="good_num">
  72. <el-input
  73. placeholder="0"
  74. disabled
  75. v-model="ruleForm.good_num"
  76. maxlength="100"
  77. />
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="8">
  81. <el-form-item label="商品重量" prop="weight">
  82. <el-input
  83. placeholder="0"
  84. v-model="ruleForm.weight"
  85. maxlength="100"
  86. >
  87. <template slot="append">g</template>
  88. </el-input>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8">
  92. <el-form-item label="工艺费" prop="teach_fee">
  93. <el-input
  94. placeholder="0"
  95. v-model="ruleForm.teach_fee"
  96. maxlength="100"
  97. >
  98. <template slot="append">元</template>
  99. </el-input>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :span="8">
  103. <el-form-item label="包装费" prop="pakge_fee">
  104. <el-input
  105. placeholder="0"
  106. v-model="ruleForm.pakge_fee"
  107. maxlength="100"
  108. >
  109. <template slot="append">元</template>
  110. </el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="8">
  114. <el-form-item label="加标费" prop="mark_fee">
  115. <el-input
  116. placeholder="0"
  117. v-model="ruleForm.mark_fee"
  118. maxlength="100"
  119. >
  120. <template slot="append">元</template>
  121. </el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="8">
  125. <el-form-item label="证书费" prop="cert_fee">
  126. <el-input
  127. placeholder="0"
  128. v-model="ruleForm.cert_fee"
  129. maxlength="100"
  130. >
  131. <template slot="append">元</template>
  132. </el-input>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="8">
  136. <el-form-item label="物流费" prop="delivery_fee">
  137. <el-input
  138. placeholder="0"
  139. v-model="ruleForm.delivery_fee"
  140. maxlength="100"
  141. >
  142. <template slot="append">元</template>
  143. </el-input>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="8">
  147. <el-form-item label="开模费" prop="open_fee">
  148. <el-input
  149. placeholder="0"
  150. v-model="ruleForm.open_fee"
  151. maxlength="100"
  152. >
  153. <template slot="append">元</template>
  154. </el-input>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="8">
  158. <el-form-item label="工差重量" prop="diff_weight">
  159. <el-input
  160. placeholder="0"
  161. v-model="ruleForm.diff_weight"
  162. maxlength="100"
  163. >
  164. <template slot="append">g</template>
  165. </el-input>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="8">
  169. <el-form-item label="工差金额" prop="diff_fee">
  170. <el-input
  171. placeholder="0"
  172. v-model="ruleForm.diff_fee"
  173. maxlength="100"
  174. >
  175. <template slot="append">元</template>
  176. </el-input>
  177. </el-form-item>
  178. </el-col>
  179. <el-col :span="8" v-if="!isDisabled">
  180. <el-form-item label="裸价" prop="nake_fee">
  181. <el-input
  182. v-model="ruleForm.nake_fee"
  183. placeholder="0"
  184. maxlength="100"
  185. >
  186. <template slot="append">元</template>
  187. </el-input>
  188. </el-form-item>
  189. </el-col>
  190. <el-col :span="24"
  191. ><el-form-item label="备注" prop="remark">
  192. <el-input
  193. :disabled="isDisabled"
  194. type="textarea"
  195. maxlength="250"
  196. :autosize="{ minRows: 2, maxRows: 4 }"
  197. v-model="ruleForm.remark"
  198. /> </el-form-item
  199. ></el-col>
  200. </el-row>
  201. <el-col :span="19" class="gongshi">
  202. <el-row>
  203. <el-col :span="24">
  204. <span class="tuan chu">
  205. <span>开模费</span>
  206. <span>采购数量</span>
  207. </span>
  208. <span class="icon-span">+</span>
  209. <span class="tuan cheng"
  210. ><span class="name">商品重量(g)</span
  211. ><span class="icon-span">×</span>
  212. <span class="name">实时金价</span></span
  213. >
  214. <span class="icon-span">+</span>
  215. <span class="tuan cheng">
  216. <span class="name">工艺费</span
  217. ><span class="icon-span">×</span>
  218. <span class="name">商品重量(g)</span>
  219. </span>
  220. <span class="icon-span">+</span>
  221. <span class="label">包装费</span
  222. ><span class="icon-span">+</span>
  223. <span class="label">裸价</span
  224. ><span class="icon-span">+</span>
  225. <span class="label">加标费</span
  226. ><span class="icon-span">+</span>
  227. <span class="label">证书费</span>
  228. <span class="icon-span">+</span>
  229. <span class="label">物流费</span
  230. ><span class="icon-span">=</span>
  231. </el-col>
  232. <el-col :span="24">
  233. <span class="label">参考商品单价:</span>
  234. <span class="good_price">{{ good_price }}</span>
  235. </el-col>
  236. </el-row>
  237. </el-col>
  238. <el-col :span="5" style="text-align: right">
  239. <el-button type="primary" @click="submitForm">保 存 </el-button>
  240. <el-button @click="showModelThis = false">关 闭</el-button>
  241. </el-col>
  242. </el-row>
  243. </el-form>
  244. </el-col>
  245. </el-row>
  246. </el-card>
  247. </el-dialog>
  248. </template>
  249. <script>
  250. import asyncRequest from "@/apis/service/purchaseIn/purchaseOrder/detail";
  251. import resToken from "@/mixins/resToken";
  252. import rules from "./rules";
  253. export default {
  254. name: "Account",
  255. props: ["showModel", "id", "sitem"],
  256. mixins: [resToken],
  257. data() {
  258. return {
  259. roleList: [],
  260. loading: false,
  261. title: "修改采购反馈",
  262. organizeList: [],
  263. showModelThis: this.showModel,
  264. rulesThis: this.rules,
  265. supplierName: "",
  266. good_price: "0",
  267. lasttime: "",
  268. ruleForm: {
  269. nake_fee: "", //裸价
  270. wsm_code: "", //仓库
  271. supplier_code: "", //供应商
  272. supplierNo: [], //采购供应商编码
  273. good_num: "",
  274. expecttime: "",
  275. weight: "",
  276. now_god_price: "",
  277. teach_fee: "",
  278. pakge_fee: "",
  279. mark_fee: "",
  280. cert_fee: "",
  281. delivery_fee: "",
  282. open_fee: "",
  283. diff_weight: "",
  284. diff_fee: "",
  285. remark: "",
  286. },
  287. rules: rules,
  288. };
  289. },
  290. watch: {
  291. showModel: function (val) {
  292. this.showModelThis = val;
  293. if (val) {
  294. this.initForm();
  295. }
  296. },
  297. showModelThis(val) {
  298. if (!val) {
  299. this.$emit("cancel");
  300. }
  301. },
  302. },
  303. methods: {
  304. closeModel() {
  305. console.log("closeModel!!");
  306. },
  307. async initForm() {
  308. this.loading = true;
  309. this.rulesThis = this.rules;
  310. await this.resetForm();
  311. this.loading = false;
  312. },
  313. // 选择供应商
  314. selectSupplier(e) {
  315. if (e && e.id) {
  316. this.ruleForm.supplierNo = [e.code];
  317. } else {
  318. this.ruleForm.supplierNo = [];
  319. this.ruleForm.stock_code = [];
  320. }
  321. this.$refs.ruleForm.validateField("supplierNo ");
  322. },
  323. //初始化表单
  324. async resetForm() {
  325. await this.$nextTick(() => {
  326. if (this.$refs.ruleForm) {
  327. this.$refs.ruleForm.resetFields();
  328. this.$refs.ruleForm.clearValidate();
  329. const {
  330. good_price,
  331. nake_fee,
  332. wsm_code,
  333. supplierNo,
  334. weight,
  335. now_god_price,
  336. teach_fee,
  337. pakge_fee,
  338. mark_fee,
  339. cert_fee,
  340. delivery_fee,
  341. open_fee,
  342. diff_weight,
  343. diff_fee,
  344. remark,
  345. good_num,
  346. supplier_name,
  347. lasttime,
  348. } = this.sitem;
  349. this.good_price = good_price || "0";
  350. this.supplierName = supplier_name;
  351. this.lasttime = lasttime || "";
  352. this.ruleForm = {
  353. cgdNo: this.id,
  354. nake_fee: nake_fee || "0", //裸价
  355. wsm_code: wsm_code || "", //仓库
  356. cgder_id: "",
  357. supplierNo: supplierNo ? [supplierNo] : [], //采购供应商
  358. good_num: good_num || "0",
  359. expecttime: lasttime || "", //预计入库时间
  360. weight: weight ? parseInt(weight + "") + "" : "0", //贵金属重量
  361. now_god_price: now_god_price || "10", //实时金价
  362. teach_fee: teach_fee || "0", //工艺费
  363. pakge_fee: pakge_fee || "0", //包装费
  364. mark_fee: mark_fee || "0", //加标费
  365. cert_fee: cert_fee || "0", //证书费
  366. delivery_fee: delivery_fee || "0", //物流费
  367. open_fee: open_fee || "0", //开模费
  368. diff_weight: diff_weight ? parseInt(diff_weight + "") + "" : "0", //工差重量
  369. diff_fee: diff_fee || "0", //工差金额
  370. remark: remark,
  371. good_price: "",
  372. };
  373. }
  374. });
  375. },
  376. // 保存更改
  377. async submitForm() {
  378. await this.$refs.ruleForm.validate(async (valid) => {
  379. if (valid) {
  380. this.loading = true;
  381. const item = JSON.parse(JSON.stringify(this.ruleForm));
  382. item.supplierNo = item.supplierNo.toString();
  383. console.log(item);
  384. const res = await asyncRequest.update(item);
  385. this.loading = false;
  386. if (res && res.code === 0) {
  387. this.$notify.success({
  388. title: "添加成功",
  389. message: "",
  390. });
  391. this.showModelThis = false;
  392. this.$emit("refresh"); //抛出事件给详情页。
  393. } else if (res && res.code >= 100 && res.code <= 104) {
  394. await this.logout();
  395. } else {
  396. this.$message.warning(res.message);
  397. }
  398. } else {
  399. console.log("error submit!!");
  400. return false;
  401. }
  402. });
  403. },
  404. },
  405. };
  406. </script>
  407. <style lang="scss" scoped>
  408. .account {
  409. .gongshi {
  410. span {
  411. vertical-align: top;
  412. display: inline-block;
  413. color: #000;
  414. }
  415. .icon-span {
  416. padding: 0 5px;
  417. height: 40px;
  418. line-height: 40px;
  419. font-size: 20px;
  420. color: #606266;
  421. display: inline-block;
  422. // vertical-align: top;
  423. // display: inline-block;
  424. }
  425. .label {
  426. height: 40px;
  427. line-height: 40px;
  428. }
  429. .tuan {
  430. &.chu {
  431. width: 60px;
  432. height: 40px;
  433. display: inline-block;
  434. span {
  435. width: 60px;
  436. display: inline-block;
  437. line-height: 20px;
  438. text-align: center;
  439. font-size: 12px;
  440. height: 20px;
  441. &:last-child {
  442. border-top: 1px solid #606266;
  443. }
  444. }
  445. }
  446. &.cheng {
  447. .name {
  448. height: 40px;
  449. line-height: 40px;
  450. }
  451. .icon-span {
  452. line-height: 40px;
  453. font-size: 16px;
  454. padding: 0 1px;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. </style>