addForm.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392
  1. <template>
  2. <div class="salesOrderDetail">
  3. <el-row>
  4. <el-col :span="24">
  5. <el-form
  6. ref="ruleForm"
  7. :model="ruleForm"
  8. status-icon
  9. :size="'mini'"
  10. :rules="rulesThis"
  11. label-width="95px"
  12. class="demo-ruleForm"
  13. >
  14. <el-row>
  15. <el-col :span="12">
  16. <el-form-item label="销售方" prop="supplierNo">
  17. <search-work-company
  18. :type="'1'"
  19. :value="ruleForm.supplierNo"
  20. :size="'mini'"
  21. :placeholder="'销售方公司'"
  22. :disabled="false"
  23. :isDetail="false"
  24. @searchChange="supplierChange"
  25. />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="12">
  29. <el-form-item label="企业客户" prop="customer_code">
  30. <search-customer
  31. :value="ruleForm.customer_code"
  32. :size="'mini'"
  33. :names="companyName"
  34. :placeholder="'企业客户'"
  35. :disabled="false"
  36. :is-detail="true"
  37. @searchChange="customer_code_change"
  38. />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="6">
  42. <el-form-item label="所属平台" prop="platform_id">
  43. <search-terrace
  44. :value="ruleForm.platform_id"
  45. :disabled="false"
  46. :size="'mini'"
  47. :is_show="'1'"
  48. :isDetail="false"
  49. :placeholder="'所属平台'"
  50. @searchChange="platform_idsearchChange"
  51. />
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="6">
  55. <el-form-item label="平台订单号" prop="platform_order">
  56. <el-input
  57. v-model="ruleForm.platform_order"
  58. placeholder="如:PO号"
  59. maxlength="100"
  60. />
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="6">
  64. <el-form-item label="回款时间" prop="paytime">
  65. <el-date-picker
  66. v-model="ruleForm.paytime"
  67. type="date"
  68. style="width: 100%"
  69. :disabled="false"
  70. value-format="yyyy-MM-dd"
  71. :picker-options="pickerOptions"
  72. placeholder="承诺回款时间"
  73. >
  74. </el-date-picker>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="6">
  78. <el-form-item label="其他单号" prop="workNo">
  79. <el-input
  80. v-model="ruleForm.workNo"
  81. placeholder="如:业管单号"
  82. maxlength="100"
  83. />
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="12">
  87. <el-form-item
  88. :label="ruleForm.good_code === '' ? '销售商品' : ''"
  89. prop="good_code"
  90. :label-width="ruleForm.good_code === '' ? '95px' : '0'"
  91. >
  92. <el-input
  93. v-if="ruleForm.good_code === ''"
  94. v-model="ruleForm.good_code"
  95. placeholder="请选择商品"
  96. readonly
  97. maxlength="200"
  98. @focus="change_good_code"
  99. />
  100. <show-data-table
  101. v-else
  102. border
  103. style="margin: 0; padding: 0"
  104. :sitem="goods_sitem"
  105. :columns="ShowDataTableColumns"
  106. >
  107. <template slot="good_name">
  108. <img
  109. v-viewer
  110. style="width: 23px; height: 23px; margin: 0 5px 0 0"
  111. class="fl"
  112. v-if="goods_sitem.good_thumb_img"
  113. :src="goods_sitem.good_thumb_img"
  114. alt=""
  115. />
  116. <span>{{ goods_sitem.good_name }}</span>
  117. <span
  118. v-for="(si, i) in goods_sitem.specinfo"
  119. :key="si.spec_id + i"
  120. >
  121. <span>{{ i === 0 ? "--" : "__" }}</span
  122. ><span>{{ si.spec_name }}[{{ si.spec_value }}]</span>
  123. </span>
  124. </template>
  125. <template slot="good_info_img">
  126. <img
  127. class="fl"
  128. style="width: 23px; height: 23px; margin: 0 5px 0 0"
  129. v-viewer
  130. v-for="(si, i) in goods_sitem.good_info_img"
  131. :src="si"
  132. :key="si + i"
  133. />
  134. </template>
  135. <template slot="cat">
  136. <span v-for="(si, sii) in goods_sitem.cat_info" :key="si.id"
  137. ><span v-if="sii !== 0">_</span><span>{{ si.name }}</span>
  138. </span>
  139. </template>
  140. <template slot="exclusive">
  141. <span
  142. v-for="(si, sii) in goods_sitem.exclusive"
  143. :key="si.id"
  144. ><span v-if="sii !== 0">/</span><span>{{ si.name }}</span>
  145. </span>
  146. </template>
  147. <template slot="is_stock">
  148. <el-tag :size="'mini'">{{
  149. goods_sitem.is_stock === "1" ? "是" : "否"
  150. }}</el-tag>
  151. </template>
  152. <template slot="weight">
  153. <span
  154. >商品总重:{{ goods_sitem.new_weight }}/{{
  155. goods_sitem.weight_unit
  156. }}</span
  157. >
  158. <span v-if="goods_sitem.metal_id"
  159. >--{{
  160. goods_sitem.noble_weight
  161. ? goods_sitem.noble_weight
  162. : "0"
  163. }}g--{{ goods_sitem.metal_name }}---{{
  164. goods_sitem.gold_price ? goods_sitem.gold_price : "0"
  165. }}元/g--{{
  166. goods_sitem.is_gold_price === "0" ? "不" : ""
  167. }}启用实时金价--{{
  168. goods_sitem.is_diff === "1" ? "有" : "无"
  169. }}工差--{{ goods_sitem.config }}---{{
  170. goods_sitem.other_config
  171. }}</span
  172. >
  173. </template>
  174. </show-data-table>
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="12" v-show="ruleForm.good_code">
  178. <el-row>
  179. <el-col :span="16">
  180. <el-form-item label="活动类型" prop="goodtype">
  181. <el-cascader
  182. v-model="ruleForm.goodtype"
  183. :options="goodtype_options"
  184. placeholder="活动类型"
  185. style="width: 100%"
  186. :props="{ expandTrigger: 'hover' }"
  187. @change="get_new_price"
  188. ></el-cascader>
  189. </el-form-item>
  190. </el-col>
  191. <el-col :span="8">
  192. <el-form-item label="剩余库存" label-width="75px">
  193. <el-input
  194. v-model="ruleForm.activity_stock"
  195. disabled
  196. maxlength="200"
  197. placeholder="剩余库存"
  198. /> </el-form-item
  199. ></el-col>
  200. <!-- <el-col :span="12">
  201. <el-form-item label="凭证文件" prop="proof_id">
  202. <el-tooltip
  203. effect="dark"
  204. content="查找历史凭证"
  205. placement="top"
  206. class="fr"
  207. >
  208. <i
  209. class="el-icon-search tb-icon"
  210. @click="showVoucherFun"
  211. ></i>
  212. </el-tooltip>
  213. <el-tooltip
  214. effect="dark"
  215. v-if="ruleForm.proof_url"
  216. content="删除"
  217. placement="top"
  218. class="fr"
  219. >
  220. <i
  221. class="el-icon-circle-close tb-icon"
  222. @click="proof_close"
  223. ></i>
  224. </el-tooltip>
  225. <ul class="shangchuan-ul">
  226. <li v-if="ruleForm.proof_url" class="shiping">
  227. <div
  228. v-if="ruleForm.proof_type === '1'"
  229. class="clearfix"
  230. >
  231. <i
  232. class="el-icon-video-camera hover fl"
  233. style="
  234. width: 28px;
  235. height: 28px;
  236. font-size: 20px;
  237. line-height: 28px;
  238. text-align: center;
  239. background: rgb(0, 0, 0);
  240. color: rgb(255, 255, 255);
  241. "
  242. />
  243. <video width="250" controls class="fl">
  244. <source :src="ruleForm.proof_url" type="video/mp4" />
  245. <source :src="ruleForm.proof_url" type="video/avi" />
  246. 您的浏览器不支持Video标签。
  247. </video>
  248. </div>
  249. <div
  250. v-else-if="ruleForm.proof_type === '2'"
  251. class="clearfix"
  252. >
  253. <img
  254. style="width: 28px; height: 28px"
  255. :src="ruleForm.proof_url"
  256. class="avatar fl"
  257. />
  258. </div>
  259. <div v-else class="clearfix">
  260. <a :href="ruleForm.proof_url" download="凭证文件"
  261. >点击下载</a
  262. >
  263. </div>
  264. </li>
  265. <li v-else class="shiping">暂无凭证</li>
  266. </ul>
  267. </el-form-item>
  268. </el-col> -->
  269. <el-col :span="12">
  270. <el-form-item label="销售数量" prop="good_num">
  271. <digital-input
  272. :values="ruleForm.good_num"
  273. :name="'ruleForm.good_num'"
  274. :placeholder="'销售数量'"
  275. :min="0"
  276. :disabled="false"
  277. :max="100000000000"
  278. :position="'right'"
  279. :precision="0"
  280. :size="'mini'"
  281. :controls="false"
  282. :append="''"
  283. @reschange="number_change($event, 'good_num')"
  284. />
  285. </el-form-item>
  286. </el-col>
  287. <el-col :span="12">
  288. <el-form-item label="销售单价" prop="good_price">
  289. <el-input
  290. v-model="ruleForm.good_price"
  291. disabled
  292. maxlength="20"
  293. v-loading="priceLoding"
  294. >
  295. <template slot="append">元</template></el-input
  296. >
  297. </el-form-item>
  298. </el-col>
  299. </el-row>
  300. </el-col>
  301. <el-col :span="6">
  302. <el-form-item label="到货时间" prop="arrtime">
  303. <el-date-picker
  304. v-model="ruleForm.arrtime"
  305. type="date"
  306. style="width: 100%"
  307. :disabled="false"
  308. value-format="yyyy-MM-dd"
  309. :picker-options="pickerOptions"
  310. placeholder="要求到货时间"
  311. >
  312. </el-date-picker>
  313. </el-form-item>
  314. </el-col>
  315. <el-col :span="6">
  316. <el-form-item label="发货方式" prop="sendtype">
  317. <el-select
  318. v-model="ruleForm.sendtype"
  319. placeholder="发货方式"
  320. style="width: 100%"
  321. >
  322. <el-option
  323. v-for="item in sendtype_options"
  324. :key="item.value"
  325. :label="item.label"
  326. :value="item.value"
  327. >
  328. </el-option>
  329. </el-select>
  330. </el-form-item>
  331. </el-col>
  332. <el-col :span="ruleForm.good_code ? 12 : 24">
  333. <el-form-item label="订单备注" prop="remark">
  334. <el-input
  335. type="textarea"
  336. maxlength="250"
  337. show-word-limit
  338. :rows="ruleForm.good_code ? 4 : 2"
  339. placeholder="订单备注"
  340. v-model="ruleForm.remark"
  341. >
  342. </el-input>
  343. </el-form-item>
  344. </el-col>
  345. <el-col :span="24">
  346. <search-good-online-modal
  347. :once="true"
  348. :sitem="addshowModel"
  349. :active="true"
  350. :show-model="showModel"
  351. @resultList="resultList"
  352. @cancel="showModel = false"
  353. />
  354. </el-col>
  355. </el-row>
  356. </el-form>
  357. </el-col>
  358. <el-col
  359. :span="24"
  360. style="padding: 0 0 22px 0"
  361. v-if="ruleForm.sendtype && ruleForm.sendtype === '1'"
  362. >
  363. <el-form :model="addrForm" ref="addrForm" :size="'mini'">
  364. <el-table
  365. :data="addrForm.order_addr"
  366. border
  367. :size="'mini'"
  368. style="width: 100%"
  369. max-height="200px"
  370. row-key="key"
  371. >
  372. <el-table-column type="index" width="50" show-overflow-tooltip />
  373. <el-table-column
  374. prop="receipt_quantity"
  375. label="收货总数"
  376. min-width="125"
  377. show-overflow-tooltip
  378. >
  379. <template slot-scope="scope">
  380. <el-form-item
  381. v-if="scope.row.edit"
  382. :prop="
  383. 'order_addr.' + scope.$index + '.' + 'receipt_quantity'
  384. "
  385. :rules="addrRules.receipt_quantity"
  386. :size="'mini'"
  387. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  388. >
  389. <el-input
  390. v-model="scope.row.receipt_quantity"
  391. placeholder="收货总数"
  392. maxlength="20"
  393. :disabled="!scope.row.edit"
  394. />
  395. </el-form-item>
  396. <span v-if="!scope.row.edit">{{
  397. scope.row.receipt_quantity
  398. }}</span>
  399. </template>
  400. </el-table-column>
  401. <el-table-column
  402. prop="contactor"
  403. label="收件联系人"
  404. min-width="110"
  405. show-overflow-tooltip
  406. >
  407. <template slot-scope="scope">
  408. <el-form-item
  409. v-if="scope.row.edit"
  410. :prop="'order_addr.' + scope.$index + '.' + 'contactor'"
  411. :rules="addrRules.contactor"
  412. :size="'mini'"
  413. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  414. >
  415. <el-input
  416. v-model="scope.row.contactor"
  417. placeholder="收件联系人"
  418. maxlength="20"
  419. :disabled="!scope.row.edit"
  420. />
  421. </el-form-item>
  422. <span v-if="!scope.row.edit">{{ scope.row.contactor }}</span>
  423. </template>
  424. </el-table-column>
  425. <el-table-column
  426. prop="mobile"
  427. label="收货联系电话"
  428. min-width="130"
  429. show-overflow-tooltip
  430. >
  431. <template slot-scope="scope">
  432. <el-form-item
  433. v-if="scope.row.edit"
  434. :prop="'order_addr.' + scope.$index + '.' + 'mobile'"
  435. :rules="addrRules.mobile"
  436. :size="'mini'"
  437. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  438. >
  439. <el-input
  440. v-model="scope.row.mobile"
  441. placeholder="收货联系电话"
  442. maxlength="11"
  443. :disabled="!scope.row.edit"
  444. />
  445. </el-form-item>
  446. <span v-if="!scope.row.edit">{{ scope.row.mobile }}</span>
  447. </template>
  448. </el-table-column>
  449. <el-table-column
  450. prop="addr_code"
  451. label="收货省市区"
  452. min-width="230"
  453. show-overflow-tooltip
  454. >
  455. <template slot-scope="scope">
  456. <el-form-item
  457. v-if="scope.row.edit"
  458. :prop="'order_addr.' + scope.$index + '.' + 'addr_code'"
  459. :rules="addrRules.addr_code"
  460. :size="'mini'"
  461. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  462. >
  463. <select-area
  464. :value="scope.row.addr_code"
  465. placeholder="收货省市区"
  466. :disabled="!scope.row.edit"
  467. :size="'mini'"
  468. @selectChange="select_area_change($event, scope.$index)"
  469. />
  470. </el-form-item>
  471. <span v-if="!scope.row.edit">{{
  472. scope.row.addr_code_name
  473. }}</span>
  474. </template>
  475. </el-table-column>
  476. <el-table-column
  477. prop="addr"
  478. label="详细地址"
  479. min-width="170"
  480. show-overflow-tooltip
  481. >
  482. <template slot-scope="scope">
  483. <el-form-item
  484. v-if="scope.row.edit"
  485. :prop="'order_addr.' + scope.$index + '.' + 'addr'"
  486. :rules="addrRules.addr"
  487. :size="'mini'"
  488. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  489. >
  490. <el-input
  491. v-model="scope.row.addr"
  492. placeholder="详细地址"
  493. maxlength="100"
  494. :disabled="!scope.row.edit"
  495. />
  496. </el-form-item>
  497. <span v-if="!scope.row.edit">{{ scope.row.addr }}</span>
  498. </template>
  499. </el-table-column>
  500. <el-table-column fixed="right" width="94" show-overflow-tooltip>
  501. <template slot="header" slot-scope="scope">
  502. <el-tooltip
  503. class="fr"
  504. style="margin: 3px 0 0 8px"
  505. effect="dark"
  506. content="手动添加地址"
  507. placement="top"
  508. >
  509. <i
  510. class="el-icon-circle-plus-outline tb-icon"
  511. style="color: #63cbe7"
  512. @click="openHouseModal(-1)"
  513. ></i>
  514. </el-tooltip>
  515. <el-tooltip
  516. class="fr"
  517. style="margin: 3px 0 0 8px"
  518. effect="dark"
  519. content="导入收货地址"
  520. placement="top"
  521. >
  522. <i
  523. class="el-icon-upload2 tb-icon"
  524. style="color: #63cbe7"
  525. @click="addrmodel = true"
  526. ></i>
  527. </el-tooltip>
  528. <el-tooltip
  529. class="fr"
  530. style="margin: 3px 0 0 0"
  531. effect="dark"
  532. content="下载收货地址模板"
  533. placement="top"
  534. >
  535. <a class="downloadAddr" href="./static/收货地址模板.xlsx">
  536. <i
  537. class="el-icon-download tb-icon"
  538. style="color: #63cbe7; margin: 0"
  539. ></i>
  540. </a>
  541. </el-tooltip>
  542. </template>
  543. <template slot-scope="scope">
  544. <el-tooltip
  545. effect="dark"
  546. content="编辑"
  547. v-if="!scope.row.edit"
  548. placement="top"
  549. >
  550. <i
  551. class="el-icon-edit tb-icon"
  552. @click="openHouseModal(scope.$index)"
  553. ></i>
  554. </el-tooltip>
  555. <el-tooltip
  556. effect="dark"
  557. content="保存"
  558. v-if="scope.row.edit"
  559. placement="top"
  560. >
  561. <i
  562. class="el-icon-circle-check tb-icon"
  563. @click="checkRow(scope.$index)"
  564. ></i>
  565. </el-tooltip>
  566. <el-tooltip effect="dark" content="删除" placement="top">
  567. <i
  568. class="el-icon-delete tb-icon"
  569. @click="deleteRow(scope.$index, addrForm.order_addr)"
  570. ></i>
  571. </el-tooltip>
  572. </template>
  573. </el-table-column>
  574. </el-table>
  575. </el-form>
  576. </el-col>
  577. <el-col :span="24">
  578. <in-addr-model
  579. :show-model="addrmodel"
  580. @cancel="addrmodel = false"
  581. @refresh="addrRefresh"
  582. />
  583. <!-- <show-voucher-model
  584. :showModel="showVoucher"
  585. :id="goods_sitem.spuCode"
  586. @cancel="showVoucher = false"
  587. @searchChange="resvoucher"
  588. /> -->
  589. </el-col>
  590. <el-col
  591. :span="24"
  592. style="
  593. text-align: right;
  594. padding: 0 0 20px 0;
  595. display: flex;
  596. justify-content: space-between;
  597. "
  598. >
  599. <p>
  600. 订单总金额:{{ accMul(ruleForm.good_num, ruleForm.good_price) || 0 }}
  601. </p>
  602. <el-button :size="'mini'" type="primary" @click="submitForm"
  603. >保 存
  604. </el-button>
  605. </el-col>
  606. </el-row>
  607. </div>
  608. </template>
  609. <script>
  610. import mixinPage from "@/mixins/elPaginationHandle";
  611. import resToken from "@/mixins/resToken";
  612. import asyncRequest from "@/apis/service/sellOut/salesOrder";
  613. import { isnumber, isMobile } from "@/utils/validate";
  614. import inAddrModel from "@/components/in-addr-model";
  615. import showVoucherModel from "@/components/show-voucher-model";
  616. import searchGoodOnlineModal from "@/components/search-good-online-modal";
  617. import { addColumns } from "./ShowDataTableColumns";
  618. import { mapGetters } from "vuex";
  619. export default {
  620. name: "salesOrderDetail",
  621. mixins: [mixinPage, resToken],
  622. props: ["newTime", "id", "sitem", "type"],
  623. computed: {
  624. ...mapGetters(["business_companyNo"]),
  625. },
  626. components: {
  627. inAddrModel,
  628. showVoucherModel,
  629. searchGoodOnlineModal,
  630. },
  631. watch: {
  632. newTime: function (val) {
  633. if (val) {
  634. this.initForm();
  635. }
  636. },
  637. },
  638. computed: {
  639. powers() {
  640. let tran =
  641. this.$store.getters.btnList.find(
  642. (item) => item.menu_route == "salesOrderDetail"
  643. ) || {};
  644. if (tran && tran.action && tran.action.length > 0) {
  645. return tran.action;
  646. } else {
  647. return [];
  648. }
  649. },
  650. },
  651. data() {
  652. const validatemobile = (rule, value, callback) => {
  653. if (value === "") {
  654. callback(new Error("手机号不能为空!"));
  655. } else {
  656. if (!isMobile(value)) {
  657. callback(new Error("手机号格式不正确!"));
  658. } else {
  659. callback();
  660. }
  661. }
  662. };
  663. const validateWeight = (rule, value, callback) => {
  664. if (value === "") {
  665. callback(new Error("收货总数不能为空!"));
  666. } else {
  667. if (!isnumber(value)) {
  668. callback(new Error("收货总数仅支持整数!"));
  669. } else {
  670. callback();
  671. }
  672. }
  673. };
  674. return {
  675. ShowDataTableColumns: addColumns,
  676. AddrAddEditModalIndex: -1,
  677. AddrAddEditModalSitem: {},
  678. showGoodsModel: false,
  679. showVoucher: false,
  680. companyName: "",
  681. showModel: false,
  682. addrmodel: false,
  683. addshowModel: {},
  684. pickerOptions: {
  685. disabledDate(time) {
  686. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24;
  687. },
  688. },
  689. goodtype_options: [
  690. {
  691. value: "is_activity_0",
  692. label: "不参与活动",
  693. children: [
  694. {
  695. value: "1",
  696. label: "常规商品",
  697. },
  698. {
  699. value: "2",
  700. label: "赠品",
  701. },
  702. {
  703. value: "3",
  704. label: "样品",
  705. },
  706. ],
  707. },
  708. {
  709. value: "is_activity_1",
  710. label: "参与活动",
  711. children: [],
  712. },
  713. ],
  714. sendtype_options: [
  715. {
  716. value: "1",
  717. label: "直接发货",
  718. },
  719. {
  720. value: "2",
  721. label: "延时发货",
  722. },
  723. ],
  724. ruleForm: {
  725. order_type: "1",
  726. supplierNo: "", //销售方编码
  727. customer_code: [], // 企业客户选择
  728. platform_id: "",
  729. arrtime: "", //要求到货时间
  730. // proof_id: "", //凭证ID
  731. proof_type: "", //凭证类型
  732. proof_url: "", //凭证地址
  733. activity_stock: "0",
  734. is_activity: "0", //是否参与活动,
  735. goodtype: ["is_activity_0", "1"], //活动类型
  736. good_num: "", //商品数量
  737. good_price: "0", //商品单价
  738. platform_order: "", //平台订单号
  739. paytime: "", //承诺回款时间
  740. workNo: "", //其他单号
  741. sendtype: "1", //发货方式
  742. remark: "", //备注
  743. good_code: "", // 商品编号
  744. },
  745. rulesThis: this.rules,
  746. rules: {
  747. supplierNo: [
  748. {
  749. required: true,
  750. message: "请选择销售方公司",
  751. trigger: "change",
  752. },
  753. ],
  754. customer_code: [
  755. {
  756. type: "array",
  757. required: true,
  758. message: "请选择企业客户",
  759. trigger: "change",
  760. },
  761. ],
  762. platform_id: [
  763. {
  764. required: true,
  765. message: "请选择所属平台",
  766. trigger: "change",
  767. },
  768. ],
  769. arrtime: [
  770. {
  771. required: true,
  772. message: "要求到货时间",
  773. trigger: "change",
  774. },
  775. ],
  776. // proof_id: [
  777. // {
  778. // required: true,
  779. // message: "请选择凭证文件",
  780. // trigger: "change",
  781. // },
  782. // ],
  783. goodtype: [
  784. {
  785. type: "array",
  786. required: true,
  787. message: "请选择活动类型",
  788. trigger: "change",
  789. },
  790. ],
  791. good_num: [
  792. {
  793. required: true,
  794. message: "请选择活动类型",
  795. trigger: "change",
  796. },
  797. ],
  798. sendtype: [
  799. {
  800. required: true,
  801. message: "请选择发货方式",
  802. trigger: "change",
  803. },
  804. ],
  805. good_code: [
  806. {
  807. required: true,
  808. message: "请选择销售商品",
  809. trigger: "blur",
  810. },
  811. ],
  812. remark: [
  813. {
  814. required: true,
  815. message: "备注不能为空",
  816. trigger: "blur",
  817. },
  818. ],
  819. },
  820. addrForm: {
  821. order_addr: [], //收货地址
  822. },
  823. delAddrList: [],
  824. delStockList: [],
  825. addrRules: {
  826. receipt_quantity: {
  827. required: true,
  828. validator: validateWeight,
  829. trigger: "blur",
  830. },
  831. contactor: {
  832. required: true,
  833. trigger: "blur",
  834. message: "联系人不能为空",
  835. },
  836. mobile: {
  837. required: true,
  838. validator: validatemobile,
  839. trigger: "blur",
  840. },
  841. order_addr: {
  842. type: "array",
  843. required: true,
  844. message: "收货省市区不能为空",
  845. trigger: "change",
  846. },
  847. addr: {
  848. required: true,
  849. message: "详细地址不能为空",
  850. trigger: "blur",
  851. },
  852. },
  853. loading: false,
  854. queryId: "",
  855. status: "",
  856. goods_sitem: {},
  857. order_good_num: {
  858. ogood_type: "",
  859. ogood_num: "0",
  860. },
  861. priceLoding: false,
  862. };
  863. },
  864. mounted() {
  865. this.initForm();
  866. },
  867. methods: {
  868. //乘法精度问题
  869. accMul(arg1, arg2) {
  870. var m = 0,
  871. s1 = arg1.toString(),
  872. s2 = arg2.toString();
  873. try {
  874. m += s1.split(".")[1].length;
  875. } catch (e) {}
  876. try {
  877. m += s2.split(".")[1].length;
  878. } catch (e) {}
  879. return (
  880. (Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
  881. Math.pow(10, m)
  882. );
  883. },
  884. async initForm() {
  885. this.status = "";
  886. this.queryId = this.$route.query.id;
  887. this.rulesThis = this.rules;
  888. this.resetForm();
  889. },
  890. getNewTime() {
  891. this.newTime = new Date().valueOf();
  892. },
  893. async resetForm() {
  894. // 重置
  895. await this.$nextTick(() => {
  896. if (this.$refs.ruleForm) {
  897. this.$refs.ruleForm.resetFields();
  898. this.$refs.ruleForm.clearValidate();
  899. this.ruleForm = {
  900. order_type: "1",
  901. supplierNo: this.business_companyNo || "", //销售方编码
  902. customer_code: [], // 企业客户选择
  903. platform_id: "",
  904. arrtime: "", //要求到货时间
  905. // proof_id: "", //凭证ID
  906. proof_type: "", //凭证类型
  907. proof_url: "", //凭证地址
  908. activity_stock: "0",
  909. goodtype: ["is_activity_0", "1"], //活动类型
  910. good_num: "0", //商品数量
  911. good_price: "0", //商品单价
  912. platform_order: "", //平台订单号
  913. paytime: "", //承诺回款时间
  914. workNo: "", //其他单号
  915. sendtype: "1", //发货方式
  916. remark: "", //备注
  917. good_code: "", // 商品编号
  918. };
  919. }
  920. if (this.$refs.addrForm) {
  921. this.$refs.addrForm.resetFields();
  922. this.$refs.addrForm.clearValidate();
  923. const { addrs } = this.sitem;
  924. this.addrForm = {
  925. order_addr: [],
  926. };
  927. this.delAddrList = [];
  928. if (addrs && addrs.length > 0) {
  929. addrs.forEach((v) => {
  930. const { area_code, city_code, provice_code } = v.addr_code;
  931. let model = {
  932. edit: false,
  933. receipt_quantity: v.receipt_quantity || "",
  934. contactor: v.contactor || "",
  935. mobile: v.mobile || "",
  936. addr_code:
  937. area_code && city_code && provice_code
  938. ? [provice_code, city_code, area_code]
  939. : [],
  940. addr: v.addr || "",
  941. id: v.id,
  942. is_del: 0,
  943. };
  944. this.delAddrList.push(model);
  945. this.addrForm.order_addr.push(model);
  946. });
  947. }
  948. }
  949. });
  950. },
  951. // resvoucher(e) {
  952. // const { id, proof_type, proof_url } = e;
  953. // this.ruleForm.proof_id = id || "";
  954. // this.ruleForm.proof_type = proof_type || "";
  955. // this.ruleForm.proof_url = proof_url || "";
  956. // this.$refs.ruleForm.validateField("proof_id");
  957. // this.showVoucher = false;
  958. // },
  959. // proof_close() {
  960. // this.ruleForm.proof_id = "";
  961. // this.ruleForm.proof_type = "";
  962. // this.ruleForm.proof_url = "";
  963. // this.$refs.ruleForm.validateField("proof_id");
  964. // },
  965. addrRefresh(e) {
  966. const { list } = e;
  967. this.addrForm.order_addr.push(...list);
  968. },
  969. async resultList(e) {
  970. this.showModel = false;
  971. if (e.length === 1) {
  972. let ssitem = JSON.parse(JSON.stringify(e[0]));
  973. await this.get_goods_detail(ssitem.skuCode);
  974. this.ruleForm.good_code = this.goods_sitem.skuCode;
  975. } else {
  976. this.goods_sitem = {};
  977. this.ruleForm.good_code = "";
  978. }
  979. this.$refs.ruleForm.validateField("good_code");
  980. // this.ruleForm.proof_id = "";
  981. // this.ruleForm.proof_url = "";
  982. // this.ruleForm.proof_type = "";
  983. // this.$refs.ruleForm.validateField("proof_id");
  984. if (e.length === 1) {
  985. await this.get_goods_active();
  986. }
  987. },
  988. async get_goods_active() {
  989. const { good_code, supplierNo, platform_id } = this.ruleForm;
  990. let model = {
  991. skuCode: good_code,
  992. companyNo: supplierNo,
  993. platform_id,
  994. };
  995. const { code, data, message } = await asyncRequest.goods_active(model);
  996. if (code === 0) {
  997. const { act, good } = data;
  998. let actlist = act.length > 0 ? JSON.parse(JSON.stringify(act)) : [];
  999. actlist.forEach((a) => {
  1000. a.value = a.activity_code;
  1001. a.label = a.activity_name;
  1002. });
  1003. this.goodtype_options[1].children = [];
  1004. this.goodtype_options[1].children.push(...actlist);
  1005. let goodItem =
  1006. good.length > 0 ? JSON.parse(JSON.stringify(good[0])) : {};
  1007. if (goodItem.good_name) {
  1008. this.goodtype_options[0].children.map((b) => {
  1009. b.activity_stock = goodItem ? goodItem.stock_num + "" : "0";
  1010. return b;
  1011. });
  1012. console.log(this.goodtype_options);
  1013. }
  1014. } else if (code >= 100 && code <= 104) {
  1015. await this.logout();
  1016. } else {
  1017. this.$message.warning(message);
  1018. }
  1019. },
  1020. async get_goods_detail(skuCode) {
  1021. let { code, data, message } = await asyncRequest.goods_detail({
  1022. skuCode: skuCode,
  1023. });
  1024. if (code === 0) {
  1025. this.goods_sitem = data;
  1026. console.log("1111111111111111", this.goods_sitem);
  1027. this.goods_sitem.good_info_img =
  1028. this.goods_sitem.good_info_img.split(",");
  1029. const { weight } = this.goods_sitem;
  1030. let kgnum = parseInt((weight * 1) / 1000);
  1031. let gnum = (weight * 1) % 1000;
  1032. let new_weight,
  1033. weight_unit = "";
  1034. if (kgnum > 0) {
  1035. weight_unit = "Kg";
  1036. new_weight = `${kgnum}.${gnum}`;
  1037. } else {
  1038. new_weight = weight;
  1039. weight_unit = "g";
  1040. }
  1041. this.goods_sitem.new_weight = new_weight;
  1042. this.goods_sitem.weight_unit = weight_unit;
  1043. this.ruleForm.good_code = this.goods_sitem.good_code;
  1044. } else if (code >= 100 && code <= 104) {
  1045. await this.logout();
  1046. } else {
  1047. this.$message.warning(message);
  1048. }
  1049. },
  1050. showVoucherFun() {
  1051. if (this.goods_sitem && this.goods_sitem.spuCode) {
  1052. this.showVoucher = true;
  1053. } else {
  1054. this.$message.warning("请选择商品!");
  1055. return;
  1056. }
  1057. },
  1058. async addGoodsRes(e) {
  1059. if (e && e.length === 1) {
  1060. this.ruleForm.good_name = e[0].good_name;
  1061. this.ruleForm.good_code = e[0].type_code;
  1062. } else {
  1063. this.ruleForm.good_name = "";
  1064. this.ruleForm.good_code = "";
  1065. }
  1066. this.$refs.ruleForm.validateField("good_code");
  1067. if (this.ruleForm.good_code !== "" && this.queryId === "add") {
  1068. } else {
  1069. }
  1070. },
  1071. async number_change(e, key) {
  1072. this.ruleForm[key] = e + "" || "0";
  1073. this.$refs.ruleForm.validateField(key);
  1074. if (key === "good_num") {
  1075. await this.get_new_price();
  1076. }
  1077. },
  1078. async get_new_price() {
  1079. const { goodtype, good_num } = this.ruleForm;
  1080. let oldGood_type = goodtype.length === 2 ? goodtype[1] : "";
  1081. if (oldGood_type == 2 || oldGood_type == 3) {
  1082. this.ruleForm.good_price = 0;
  1083. }
  1084. const { ogood_type, ogood_num } = this.order_good_num;
  1085. console.log(
  1086. `oldGood_type${oldGood_type}-ogood_type${ogood_type}-good_num${good_num}-ogood_num${ogood_num}`
  1087. );
  1088. if (oldGood_type === ogood_type && good_num === ogood_num) {
  1089. this.order_good_num = {
  1090. ogood_type: goodtype.length === 2 ? goodtype[1] : "",
  1091. ogood_num: this.ruleForm.good_num,
  1092. };
  1093. return;
  1094. }
  1095. //activity_stock
  1096. if (goodtype.length === 2) {
  1097. this.goodtype_options.forEach((a) => {
  1098. if (a.children && a.children.length) {
  1099. a.children.forEach((b) => {
  1100. if (b.value === goodtype[1]) {
  1101. console.log(b.activity_stock);
  1102. this.ruleForm.activity_stock = b.activity_stock || "0";
  1103. }
  1104. });
  1105. }
  1106. });
  1107. } else {
  1108. this.ruleForm.activity_stock = 0 + "";
  1109. }
  1110. if (!this.priceLoding) {
  1111. const { isok, price, stock } = await this.set_salegetprice();
  1112. this.ruleForm.good_price = isok ? price : "0";
  1113. }
  1114. this.order_good_num = {
  1115. ogood_type: goodtype.length === 2 ? goodtype[1] : "",
  1116. ogood_num: this.ruleForm.good_num,
  1117. };
  1118. },
  1119. change_good_code() {
  1120. const { supplierNo, platform_id } = this.ruleForm;
  1121. if (supplierNo === "") {
  1122. this.$message.warning("请选择销售方公司!");
  1123. return;
  1124. }
  1125. if (platform_id === "") {
  1126. this.$message.warning("请选择所属平台!");
  1127. return;
  1128. }
  1129. this.addshowModel = {
  1130. company_id: supplierNo,
  1131. platform_code: platform_id,
  1132. };
  1133. this.showModel = true;
  1134. },
  1135. customer_code_change(e) {
  1136. if (e && e.code) {
  1137. this.ruleForm.customer_code = [e.code];
  1138. } else {
  1139. this.ruleForm.customer_code = [];
  1140. }
  1141. this.$refs.ruleForm.validateField("customer_code");
  1142. },
  1143. supplierChange(e) {
  1144. const { id, code, label } = e;
  1145. this.ruleForm.supplierNo = code || "";
  1146. this.$refs.ruleForm.validateField("supplierNo");
  1147. // this.ruleForm.proof_id = "";
  1148. // this.ruleForm.proof_url = "";
  1149. // this.ruleForm.proof_type = "";
  1150. // this.$refs.ruleForm.validateField("proof_id");
  1151. this.ruleForm.good_code = "";
  1152. this.goods_sitem = {};
  1153. // this.$refs.ruleForm.validateField("proof_id");
  1154. },
  1155. platform_idsearchChange(e) {
  1156. const { id, code, label } = e;
  1157. this.ruleForm.platform_id = id || "";
  1158. this.$refs.ruleForm.validateField("platform_id");
  1159. // this.ruleForm.proof_id = "";
  1160. // this.ruleForm.proof_url = "";
  1161. // this.ruleForm.proof_type = "";
  1162. // this.$refs.ruleForm.validateField("proof_id");
  1163. this.ruleForm.good_code = "";
  1164. this.goods_sitem = {};
  1165. // this.$refs.ruleForm.validateField("proof_id");
  1166. },
  1167. openHouseModal(index) {
  1168. let findex = this.addrForm.order_addr.findIndex((v) => v.edit === true);
  1169. if (findex !== -1) {
  1170. this.$message.warning("当前已有地址在编辑,请保存后再试!");
  1171. return;
  1172. } else {
  1173. if (index === -1) {
  1174. this.addrForm.order_addr.push({
  1175. edit: true,
  1176. receipt_quantity: "",
  1177. contactor: "",
  1178. mobile: "",
  1179. addr_code: [],
  1180. addr: "",
  1181. });
  1182. } else {
  1183. this.addrForm.order_addr[index].edit = true;
  1184. }
  1185. }
  1186. },
  1187. //省市区选择
  1188. select_area_change(e, index) {
  1189. this.addrForm.order_addr[index].addr_code = e;
  1190. },
  1191. //省市区保存某一行
  1192. async checkRow(rowIndex) {
  1193. await this.$refs.addrForm.validate(async (valid) => {
  1194. if (valid) {
  1195. const { addr_code } = this.addrForm.order_addr[rowIndex];
  1196. if (addr_code && addr_code.length === 3) {
  1197. let arrCode = addr_code[addr_code.length - 1];
  1198. // console.log(model);
  1199. let { code, data, message } = await asyncRequest.addrall({
  1200. code: arrCode,
  1201. });
  1202. if (code === 0) {
  1203. const { province, city, area } = data;
  1204. let province_name =
  1205. province && province.name ? province.name : "";
  1206. let city_name = city && city.name ? city.name : "";
  1207. let area_name = area && area.name ? area.name : "";
  1208. this.addrForm.order_addr[rowIndex].addr_code_name =
  1209. province_name && city_name && area_name
  1210. ? `${province_name}/${city_name}/${area_name}`
  1211. : "";
  1212. } else if (code >= 100 && code <= 104) {
  1213. await this.logout();
  1214. } else {
  1215. this.$message.warning(message);
  1216. }
  1217. } else {
  1218. this.addrForm.order_addr[rowIndex].addr_code_name = "";
  1219. }
  1220. this.addrForm.order_addr[rowIndex].edit = false;
  1221. } else {
  1222. console.log("error submit!!");
  1223. return false;
  1224. }
  1225. });
  1226. },
  1227. // 删除收货地址操作
  1228. deleteRow(index, rows) {
  1229. rows.splice(index, 1);
  1230. },
  1231. async submitForm() {
  1232. await this.$refs.ruleForm.validate(async (valid) => {
  1233. if (valid) {
  1234. this.loading = true;
  1235. const { sendtype, good_num, goodtype } = JSON.parse(
  1236. JSON.stringify(this.ruleForm)
  1237. );
  1238. const { order_addr } = JSON.parse(JSON.stringify(this.addrForm));
  1239. let key_0 = goodtype[0];
  1240. let key_1 = goodtype[1];
  1241. if (order_addr.length === 0 && sendtype === "1") {
  1242. this.$message.warning("至少填写一条地址信息!");
  1243. this.loading = false;
  1244. return;
  1245. }
  1246. let model = JSON.parse(JSON.stringify(this.ruleForm));
  1247. model.addrlist = [];
  1248. model.customer_code = model.customer_code.toString();
  1249. delete model["proof_type"];
  1250. delete model["proof_url"];
  1251. delete model["good_price"];
  1252. if (sendtype === "1") {
  1253. let addrT = 0,
  1254. isAEdit = false;
  1255. order_addr.forEach((v2) => {
  1256. if (v2.edit) {
  1257. isAEdit = true;
  1258. }
  1259. addrT += parseInt(v2.receipt_quantity);
  1260. let model2 = {
  1261. contactor: v2.contactor,
  1262. mobile: v2.mobile,
  1263. addr: v2.addr,
  1264. receipt_quantity: v2.receipt_quantity,
  1265. addr_code: v2.addr_code,
  1266. };
  1267. model.addrlist.push(model2);
  1268. });
  1269. if (isAEdit) {
  1270. this.$message.warning("请保存地址信息!");
  1271. this.loading = false;
  1272. return;
  1273. }
  1274. if (good_num * 1 !== addrT) {
  1275. this.$message.warning("地址收货总数与销售总数量不一致!");
  1276. this.loading = false;
  1277. return;
  1278. }
  1279. }
  1280. let priceres = await this.set_salegetprice();
  1281. if (!priceres.isok) {
  1282. this.loading = false;
  1283. return;
  1284. }
  1285. model.is_activity = key_0 === "is_activity_0" ? "0" : "1";
  1286. model.goodtype = key_0 === "is_activity_1" ? "1" : key_1;
  1287. model.act_code = key_0 === "is_activity_1" ? Fkey_1 : "";
  1288. let res = await asyncRequest.add(model);
  1289. this.loading = false;
  1290. if (res && res.code === 0) {
  1291. this.$notify.success({
  1292. title: "订单创建成功!",
  1293. message: "",
  1294. });
  1295. this.$emit("refresh");
  1296. } else if (res && res.code >= 100 && res.code <= 104) {
  1297. await this.logout();
  1298. } else {
  1299. this.$message.warning(res.message);
  1300. }
  1301. } else {
  1302. console.log("error submit!!");
  1303. return false;
  1304. }
  1305. });
  1306. },
  1307. async set_salegetprice() {
  1308. this.priceLoding = true;
  1309. let resModel = {
  1310. isok: true,
  1311. price: "0",
  1312. };
  1313. const { good_num, good_code, goodtype } = this.ruleForm;
  1314. let key_1 = goodtype[1];
  1315. let key_0 = goodtype[0];
  1316. let model = {
  1317. skuCode: good_code,
  1318. sale_num: good_num,
  1319. is_activity: key_0 === "is_activity_0" ? "0" : "1",
  1320. act_code: key_0 === "is_activity_1" ? key_1 : "",
  1321. };
  1322. console.log(model);
  1323. let { code, message, data } = await asyncRequest.salegetprice(model);
  1324. console.log(code, message, data);
  1325. if (code === 0) {
  1326. const { sale_price } = data;
  1327. resModel.price = sale_price + "";
  1328. let oldGood_type = goodtype.length === 2 ? goodtype[1] : "";
  1329. if (
  1330. key_0 === "is_activity_0" &&
  1331. (oldGood_type == 2 || oldGood_type == 3)
  1332. ) {
  1333. resModel.price = 0 + "";
  1334. }
  1335. } else if (code >= 100 && code <= 104) {
  1336. await this.logout();
  1337. } else {
  1338. this.$message.warning(message);
  1339. resModel.isok = false;
  1340. }
  1341. this.priceLoding = false;
  1342. return resModel;
  1343. },
  1344. },
  1345. };
  1346. </script>
  1347. <style lang="scss" scoped>
  1348. .salesOrderDetail {
  1349. }
  1350. </style>