addForm.vue 45 KB

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