order.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. <template>
  2. <div>
  3. <div style="padding: 8px; text-align: center" v-if="formData.data.code || formData.data.wlnCode">
  4. <span style="font-size: 18px; font-weight: 700">{{ formData.data.code }} </span>
  5. <span style="font-size: 18px; font-weight: 700" v-if="formData.data.wlnCode"> ({{ formData.data.wlnCode }})</span>
  6. </div>
  7. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  8. <template #type>
  9. <div style="width: 100%">
  10. <el-radio-group v-model="formData.data.type">
  11. <el-radio v-for="(itemType, index) in typeList" :key="index" :label="itemType.dictKey">{{ itemType.dictValue }}</el-radio>
  12. </el-radio-group>
  13. </div>
  14. </template>
  15. <template #departmentId>
  16. <div style="width: 100%">
  17. <el-select v-model="formData.data.departmentId" placeholder="请选择事业部" clearable style="width: 100%">
  18. <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  19. </el-select>
  20. </div>
  21. </template>
  22. <template #deliveryAddress>
  23. <div style="width: 100%">
  24. <el-row>
  25. <el-col :span="3">
  26. <el-form-item label-width="0" prop="province" style="width: 100%">
  27. <el-input v-model="formData.data.province" placeholder="请输入省" />
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="3">
  31. <el-form-item label-width="0" prop="city" style="width: 100%">
  32. <el-input v-model="formData.data.city" placeholder="请输入市" />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="3">
  36. <el-form-item label-width="0" prop="county" style="width: 100%">
  37. <el-input v-model="formData.data.county" placeholder="请输入区/县" />
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="11">
  41. <el-form-item label-width="0" prop="detailedAddress" style="width: 100%">
  42. <el-input v-model="formData.data.detailedAddress" placeholder="请输入详细地址" />
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="4">
  46. <el-form-item label-width="0" prop="postcode" style="width: 100%">
  47. <el-input v-model="formData.data.postcode" placeholder="请输入邮编" />
  48. </el-form-item>
  49. </el-col>
  50. </el-row>
  51. </div>
  52. </template>
  53. <template #consignee>
  54. <div style="width: 100%">
  55. <el-row>
  56. <el-col :span="6">
  57. <el-form-item label-width="0" prop="consignee" style="width: 100%">
  58. <el-input v-model="formData.data.consignee" placeholder="请输入联系人" />
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="6">
  62. <el-form-item label-width="0" prop="consigneeNumber" style="width: 100%">
  63. <el-input v-model="formData.data.consigneeNumber" placeholder="请输入联系电话" />
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. </div>
  68. </template>
  69. <template #orderSkuList>
  70. <div style="width: 100%; padding: 0 20px">
  71. <div style="margin-bottom: 10px" v-if="!formOption.disabled">
  72. <el-button type="primary" size="small" @click="clickAddProduct()">选择产品</el-button>
  73. </div>
  74. <div v-for="(item, index) in formData.data.orderSkuList" :key="index" style="margin-bottom: 20px">
  75. <div style="border: 1px solid #edf0f5">
  76. <el-table :data="[item]" :row-style="{ height: '35px' }" header-row-class-name="tableHeader" :cell-class-name="cellStyleName">
  77. <el-table-column label="产品" width="280">
  78. <template #default="{ row }">
  79. <div style="width: 100%">
  80. <div style="line-height: 35px">
  81. <span style="color: black; font-weight: 700">商品名称: </span>
  82. <span>{{ item.wlnSkuName }}</span>
  83. </div>
  84. <div style="line-height: 35px">
  85. <span style="color: black; font-weight: 700">品号: </span>
  86. <span>{{ item.code }}</span>
  87. </div>
  88. <div style="line-height: 35px; word-break: break-all">
  89. <span style="color: black; font-weight: 700">品名: </span>
  90. <span>{{ item.name }}</span>
  91. </div>
  92. <div style="line-height: 35px; display: flex">
  93. <span style="width: 37px; color: black; font-weight: 700">数量: </span>
  94. <el-form-item
  95. :prop="'orderSkuList.' + index + '.quantity'"
  96. :rules="rules.quantity"
  97. :inline-message="true"
  98. style="width: calc(100% - 37px)">
  99. <el-input-number
  100. onmousewheel="return false;"
  101. v-model="row.quantity"
  102. placeholder="数量"
  103. style="width: 100%"
  104. :controls="false"
  105. :min="0"
  106. :precision="0"
  107. @change="changeQuantity(index)" />
  108. </el-form-item>
  109. </div>
  110. <div style="line-height: 35px">
  111. <span style="color: black; font-weight: 700">加工费: </span>
  112. <span>{{ item.customProcessingFee }}</span>
  113. </div>
  114. <div style="line-height: 35px">
  115. <span style="color: black; font-weight: 700">代发费: </span>
  116. <span>{{ item.lssueFee }}</span>
  117. </div>
  118. <div style="line-height: 35px">
  119. <span style="color: black; font-weight: 700">快递包材费: </span>
  120. <span>{{ item.deliveryMaterialsFee }}</span>
  121. </div>
  122. <div style="line-height: 35px">
  123. <span style="color: black; font-weight: 700">包装人工费: </span>
  124. <span>{{ item.packingLabor }}</span>
  125. </div>
  126. <div style="line-height: 35px">
  127. <span style="color: black; font-weight: 700">管理费: </span>
  128. <span>{{ item.managementFee }}</span>
  129. </div>
  130. <div style="line-height: 35px">
  131. <span style="color: black; font-weight: 700">单价: </span>
  132. <span>{{ item.unitPrice }}</span>
  133. </div>
  134. <div style="line-height: 35px">
  135. <span style="color: black; font-weight: 700">小计: </span>
  136. <span>{{ getSubtotal(item) }}</span>
  137. </div>
  138. <div style="line-height: 35px">
  139. <span style="width: 37px; color: black; font-weight: 700">打印: </span>
  140. <el-form-item
  141. :prop="'orderSkuList.' + index + '.printType'"
  142. :rules="rules.printType"
  143. :inline-message="true"
  144. style="width: calc(100% - 37px)">
  145. <el-radio-group v-model="item.printType" @change="changeQuantity(index)">
  146. <el-radio v-for="(itemType, index) in printType" :key="index" :label="itemType.dictKey">{{ itemType.dictValue }}</el-radio>
  147. </el-radio-group>
  148. </el-form-item>
  149. </div>
  150. </div>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="产品图稿" width="320">
  154. <template #default="{ row }">
  155. <div style="display: flex; width: 100%">
  156. <div style="width: 80px">设计图:</div>
  157. <div style="width: calc(100% - 80px)">
  158. <el-image
  159. fit="scale-down"
  160. style="width: 148px; height: 148px; margin-right: 10px; cursor: pointer"
  161. v-if="row.blueprint"
  162. :src="row.blueprint"
  163. @click="openFile(row.blueprint)" />
  164. <div style="display: flex" v-if="!formOption.disabled">
  165. <el-button type="primary" @click="clickDrawingFile(index)" text>选择图稿</el-button>
  166. <el-upload
  167. :show-file-list="false"
  168. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  169. :data="uploadImgData"
  170. :before-upload="uploadImgFile"
  171. :on-success="
  172. (response, uploadFile) => {
  173. return handleImgSuccess(uploadFile, index);
  174. }
  175. "
  176. style="width: 100%"
  177. accept=".docx,.jpg,.jpeg,.png,.GIF,.JPG,.PNG">
  178. <el-button type="primary" style="margin-left: 12px" text>上传图片</el-button>
  179. </el-upload>
  180. </div>
  181. </div>
  182. </div>
  183. <div style="display: flex; margin-top: 20px; width: 100%">
  184. <div style="width: 80px">图稿文件:</div>
  185. <div style="width: calc(100% - 80px)">
  186. <a
  187. style="color: #409eff; cursor: pointer; word-break: break-all; margin-right: 10px"
  188. @click="openFile(row.productionDocument)"
  189. v-if="row.productionDocument">
  190. {{ row.productionDocument }}
  191. </a>
  192. <div style="display: flex" v-if="!formOption.disabled">
  193. <el-button type="primary" @click="clickDrawingFile(index)" text>选择图稿</el-button>
  194. <el-upload
  195. :show-file-list="false"
  196. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  197. :data="uploadData"
  198. :before-upload="uploadFile"
  199. :on-success="
  200. (response, uploadFile) => {
  201. return handleSuccess(uploadFile, index);
  202. }
  203. "
  204. style="width: 100%">
  205. <el-button type="primary" style="margin-left: 12px" text>上传文件</el-button>
  206. </el-upload>
  207. </div>
  208. </div>
  209. </div>
  210. <div style="font-weight: 700; margin-top: 20px">产品不干胶图稿</div>
  211. <div style="display: flex; width: 100%">
  212. <div style="width: 80px">不干胶图片:</div>
  213. <div style="width: calc(100% - 80px)">
  214. <el-image
  215. fit="scale-down"
  216. style="width: 148px; height: 148px; margin-right: 10px; cursor: pointer"
  217. v-if="row.selfAdhesiveStickerFile && row.selfAdhesiveStickerFile.fileUrl"
  218. :src="row.selfAdhesiveStickerFile.fileUrl"
  219. @click="openFile(row.selfAdhesiveStickerFile.fileUrl)" />
  220. <div style="display: flex" v-if="!formOption.disabled">
  221. <el-upload
  222. :show-file-list="false"
  223. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  224. :data="uploadAdhesiveData"
  225. :before-upload="uploadAdhesiveFile"
  226. :on-success="
  227. (response, uploadFile) => {
  228. return handleAdhesiveSuccess(uploadFile, index);
  229. }
  230. "
  231. style="width: 100%">
  232. <el-button type="primary" text>上传文件</el-button>
  233. </el-upload>
  234. </div>
  235. </div>
  236. </div>
  237. </template>
  238. </el-table-column>
  239. <el-table-column label="包材配件/单品" min-width="600">
  240. <template #default="{ row }">
  241. <div style="width: 100%">
  242. <div style="margin-bottom: 10px" v-if="!formOption.disabled">
  243. <el-button type="primary" size="small" @click="clickPackingFittings(index)">选择包材配件</el-button>
  244. </div>
  245. <el-table :data="row.orderSkuBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  246. <el-table-column label="单价¥" width="70">
  247. <template #default="props">
  248. <div>
  249. <span>{{ moneyFormat(props.row.unitPrice, 2) }}</span>
  250. </div>
  251. </template>
  252. </el-table-column>
  253. <el-table-column label="数量" width="90">
  254. <template #default="props">
  255. <el-form-item
  256. :prop="'orderSkuList.' + index + '.orderSkuBomList.' + props.$index + '.quantity'"
  257. :rules="rules.quantity"
  258. :inline-message="true"
  259. style="width: 100%">
  260. <el-input-number
  261. onmousewheel="return false;"
  262. v-model="props.row.quantity"
  263. placeholder="数量"
  264. style="width: 100%"
  265. :controls="false"
  266. :min="0" />
  267. </el-form-item>
  268. </template>
  269. </el-table-column>
  270. <el-table-column label="名称" prop="bomSpecName" min-width="130" />
  271. <el-table-column label="总量" width="70">
  272. <template #default="props">
  273. {{ computeQuantity(index, props.$index) }}
  274. </template>
  275. </el-table-column>
  276. <el-table-column label="小计¥" width="100">
  277. <template #default="props">
  278. {{ moneyFormat(computeMoney(index, props.$index), 2) }}
  279. </template>
  280. </el-table-column>
  281. <el-table-column label="操作" align="center" fixed="right" width="60" v-if="!formOption.disabled">
  282. <template #default="props">
  283. <el-button type="danger" @click="clickDeletePackingFittings(index, props.$index)" text>删除</el-button>
  284. </template>
  285. </el-table-column>
  286. </el-table>
  287. </div>
  288. </template>
  289. </el-table-column>
  290. <el-table-column label="包装要求" min-width="500">
  291. <template #default="{}">
  292. <div v-if="formOption.disabled">
  293. <div v-html="getStyle(item.packageRemark)"></div>
  294. </div>
  295. <Editor
  296. v-else
  297. :value="item.packageRemark"
  298. @updateValue="
  299. (val) => {
  300. return updatePackageRemark(val, index);
  301. }
  302. "
  303. :ref="'editor_' + index" />
  304. </template>
  305. </el-table-column>
  306. <el-table-column label="操作" align="center" fixed="right" width="60" v-if="!formOption.disabled">
  307. <template #default="{}">
  308. <el-button type="danger" @click="clickDelete(index)" text>删除</el-button>
  309. </template>
  310. </el-table-column>
  311. </el-table>
  312. </div>
  313. </div>
  314. </div>
  315. </template>
  316. <template #deliveryTime>
  317. <div style="width: 100%">
  318. <el-date-picker
  319. v-model="formData.data.deliveryTime"
  320. type="datetime"
  321. placeholder="请选择交货日期"
  322. value-format="YYYY-MM-DD HH:mm:ss"
  323. style="width: 100%" />
  324. </div>
  325. </template>
  326. <template #totalMonet>
  327. <div style="width: 100%; margin-left: 30px">
  328. <div>
  329. <span style="font-weight: 700; color: #6c88f1">产品总金额: ¥{{ moneyFormat(calculatedAmount("unitPrice"), 2) }}</span>
  330. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">
  331. 定制加工费: ¥{{ moneyFormat(calculatedAmount("customProcessingFee"), 2) }}
  332. </span>
  333. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">代发费: ¥{{ moneyFormat(calculatedAmount("lssueFee"), 2) }}</span>
  334. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">
  335. 快递包材费: ¥{{ moneyFormat(calculatedAmount("deliveryMaterialsFee"), 2) }}
  336. </span>
  337. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">包装人工费: ¥{{ moneyFormat(calculatedAmount("packingLabor"), 2) }}</span>
  338. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">包材费: ¥{{ moneyFormat(calculatedPackagingMaterialCost(), 2) }}</span>
  339. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">管理费: ¥{{ moneyFormat(calculatedAmount("managementFee"), 2) }}</span>
  340. </div>
  341. <div style="padding: 8px 0 0 0">
  342. <span style="font-weight: 700; color: red">订单总金额(含税): ¥{{ moneyFormat(calculatedTotalAmount(), 2) }}</span>
  343. </div>
  344. </div>
  345. </template>
  346. <template #attachments>
  347. <div style="width: 100%">
  348. <el-upload
  349. v-model:fileList="fileList"
  350. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  351. :data="uploadFileData"
  352. multiple
  353. :before-upload="beforeUpload"
  354. :on-success="onSuccessFile"
  355. :on-preview="onPreviewFile">
  356. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
  357. </el-upload>
  358. </div>
  359. </template>
  360. <template #remark>
  361. <div style="width: 100%">
  362. <div style="margin: 0 2vw" v-if="formOption.disabled">
  363. <div v-html="getStyle(formData.data.remark)"></div>
  364. </div>
  365. <Editor v-else :value="formData.data.remark" @updateValue="updateValue" ref="editor" />
  366. </div>
  367. </template>
  368. </byForm>
  369. <el-dialog title="选择产品" v-if="openProduct" v-model="openProduct" width="90%">
  370. <SelectProduct :selectStatus="true" :type="'null'" @selectProduct="selectProduct"></SelectProduct>
  371. <template #footer>
  372. <el-button @click="openProduct = false" size="large">关 闭</el-button>
  373. </template>
  374. </el-dialog>
  375. <el-dialog title="选择包材配件" v-if="openPackingFittings" v-model="openPackingFittings" width="90%">
  376. <SelectBOM :selectStatus="true" :bomClassifyIdList="[2, 3]" @selectBOM="selectPackingFittings"></SelectBOM>
  377. <template #footer>
  378. <el-button @click="openPackingFittings = false" size="large">关 闭</el-button>
  379. </template>
  380. </el-dialog>
  381. <el-dialog title="选择图稿文件" v-if="openDrawingFile" v-model="openDrawingFile" width="70%">
  382. <SelectPicture @selectPic="selectPic"></SelectPicture>
  383. <template #footer>
  384. <el-button @click="openDrawingFile = false" size="large">关 闭</el-button>
  385. </template>
  386. </el-dialog>
  387. </div>
  388. </template>
  389. <script setup>
  390. import byForm from "/src/components/byForm/index";
  391. import { ElMessage } from "element-plus";
  392. import Editor from "/src/components/Editor/index.vue";
  393. import { useRoute } from "vue-router";
  394. import SelectProduct from "/src/views/group/product/management/index";
  395. import SelectBOM from "/src/views/group/BOM/management/index";
  396. import SelectPicture from "/src/components/select-picture/index.vue";
  397. const { proxy } = getCurrentInstance();
  398. // 接收父组件的传值
  399. const props = defineProps({
  400. queryData: Object,
  401. });
  402. const route = useRoute();
  403. const submit = ref(null);
  404. const departmentList = ref([]);
  405. const judgeStatus = () => {
  406. if (route.query.processType == 20 || route.query.processType == 10) {
  407. return true;
  408. }
  409. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  410. let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
  411. if (data && data.length > 0) {
  412. return true;
  413. }
  414. }
  415. return false;
  416. };
  417. const formOption = reactive({
  418. inline: true,
  419. labelWidth: "120px",
  420. itemWidth: 100,
  421. rules: [],
  422. labelPosition: "right",
  423. });
  424. const formData = reactive({
  425. data: {
  426. remark: "",
  427. type: 1,
  428. orderSkuList: [],
  429. fileList: [],
  430. },
  431. });
  432. const formConfig = computed(() => {
  433. return [
  434. {
  435. type: "title",
  436. title: "类型",
  437. label: "",
  438. },
  439. {
  440. type: "slot",
  441. prop: "type",
  442. slotName: "type",
  443. label: "订单类型",
  444. },
  445. {
  446. type: "slot",
  447. prop: "departmentId",
  448. slotName: "departmentId",
  449. label: "事业部",
  450. itemWidth: 25,
  451. },
  452. {
  453. type: "title",
  454. title: "产品",
  455. label: "",
  456. },
  457. {
  458. type: "slot",
  459. prop: "orderSkuList",
  460. slotName: "orderSkuList",
  461. },
  462. formOption.disabled
  463. ? {}
  464. : {
  465. type: "title",
  466. title: "地址",
  467. label: "",
  468. },
  469. formOption.disabled
  470. ? {}
  471. : {
  472. type: "slot",
  473. slotName: "deliveryAddress",
  474. label: "收货地址",
  475. },
  476. formOption.disabled
  477. ? {}
  478. : {
  479. type: "slot",
  480. slotName: "consignee",
  481. label: "收货人",
  482. },
  483. {
  484. type: "title",
  485. title: "贸易",
  486. label: "",
  487. },
  488. {
  489. type: "slot",
  490. prop: "deliveryTime",
  491. slotName: "deliveryTime",
  492. label: "交货时间",
  493. itemWidth: 25,
  494. },
  495. {
  496. type: "select",
  497. label: "选择快递",
  498. prop: "expressDeliveryId",
  499. data: [],
  500. itemWidth: 25,
  501. clearable: true,
  502. },
  503. {
  504. type: "select",
  505. label: "店铺来源",
  506. prop: "sourcePlatform",
  507. data: proxy.useUserStore().allDict["source_platform"],
  508. itemWidth: 25,
  509. clearable: true,
  510. },
  511. {
  512. type: "select",
  513. label: "店铺名称",
  514. prop: "shopName",
  515. data: proxy.useUserStore().allDict["shop_name"],
  516. itemWidth: 25,
  517. clearable: true,
  518. },
  519. {
  520. type: "title",
  521. title: "总计",
  522. label: "",
  523. },
  524. {
  525. type: "slot",
  526. prop: "totalMonet",
  527. slotName: "totalMonet",
  528. },
  529. {
  530. type: "title",
  531. title: "附件",
  532. label: "",
  533. },
  534. {
  535. type: "slot",
  536. slotName: "attachments",
  537. label: "附件",
  538. },
  539. {
  540. type: "title",
  541. title: "订单备注",
  542. label: "",
  543. },
  544. {
  545. type: "slot",
  546. slotName: "remark",
  547. },
  548. ];
  549. });
  550. const rules = ref({
  551. province: [{ required: true, message: "请输入省", trigger: "blur" }],
  552. detailedAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  553. consignee: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  554. consigneeNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  555. deliveryTime: [{ required: true, message: "请选择交货时间", trigger: "change" }],
  556. // expressDeliveryId: [{ required: true, message: "请选择快递", trigger: "change" }],
  557. sourcePlatform: [{ required: true, message: "请选择店铺来源", trigger: "change" }],
  558. shopName: [{ required: true, message: "请选择店铺", trigger: "change" }],
  559. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  560. type: [{ required: true, message: "请选择订单类型", trigger: "change" }],
  561. departmentId: [{ required: true, message: "请选择事业部", trigger: "change" }],
  562. });
  563. const getDemandData = () => {
  564. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  565. if (res.rows && res.rows.length > 0) {
  566. departmentList.value = res.rows.map((item) => {
  567. return {
  568. dictKey: item.id,
  569. dictValue: item.name,
  570. };
  571. });
  572. }
  573. });
  574. };
  575. getDemandData();
  576. const drawingFileIndex = ref(0);
  577. const openDrawingFile = ref(false);
  578. const clickDrawingFile = (index) => {
  579. drawingFileIndex.value = index;
  580. openDrawingFile.value = true;
  581. };
  582. const selectPic = (row) => {
  583. formData.data.orderSkuList[drawingFileIndex.value].blueprint = row.imgUrl;
  584. formData.data.orderSkuList[drawingFileIndex.value].productionDocument = row.fileUrl;
  585. ElMessage({ message: "选择完成", type: "success" });
  586. openDrawingFile.value = false;
  587. };
  588. const openFile = (path) => {
  589. window.open(path);
  590. };
  591. const updatePackageRemark = (val, index) => {
  592. formData.data.orderSkuList[index].packageRemark = val;
  593. };
  594. const clickDelete = (index) => {
  595. formData.data.orderSkuList.splice(index, 1);
  596. };
  597. const updateValue = (val) => {
  598. formData.data.remark = val;
  599. };
  600. const getStyle = (text) => {
  601. if (text) {
  602. return text.replace(/\n|\r\n/g, "<br>");
  603. } else {
  604. return "";
  605. }
  606. };
  607. const openProduct = ref(false);
  608. const clickAddProduct = () => {
  609. openProduct.value = true;
  610. };
  611. const printType = ref([
  612. {
  613. dictKey: 1,
  614. dictValue: "单面",
  615. },
  616. {
  617. dictKey: 2,
  618. dictValue: "双面",
  619. },
  620. ]);
  621. const typeList = ref([
  622. {
  623. dictKey: 1,
  624. dictValue: "自主订单",
  625. },
  626. {
  627. dictKey: 2,
  628. dictValue: "委外订单",
  629. },
  630. ]);
  631. const skuDetail = ref({});
  632. const selectProduct = (row, SKU) => {
  633. if (row.id) {
  634. let list = formData.data.orderSkuList.filter((item) => item.skuSpecId === row.id && item.bomSpecId === row.bomSpecId);
  635. if (list && list.length > 0) {
  636. return ElMessage("该产品已添加");
  637. }
  638. if (skuDetail.value && skuDetail.value.id === SKU.id) {
  639. pushProduct(skuDetail.value, SKU, row);
  640. } else {
  641. proxy.post("/sku/detail", { id: SKU.id }).then((res) => {
  642. skuDetail.value = res;
  643. pushProduct(res, SKU, row);
  644. });
  645. }
  646. } else {
  647. ElMessage("添加失败");
  648. }
  649. };
  650. const pushProduct = (res, SKU, row) => {
  651. let data = proxy.deepClone(res);
  652. let orderSkuBomList = [];
  653. if (data.skuSpecList && data.skuSpecList.length > 0) {
  654. let listTwo = data.skuSpecList.filter((item) => item.id === row.id);
  655. if (listTwo && listTwo.length > 0) {
  656. if (listTwo[0].packagingMaterialList && listTwo[0].packagingMaterialList.length > 0) {
  657. orderSkuBomList = listTwo[0].packagingMaterialList.map((item) => {
  658. return {
  659. bomSpecId: item.bomSpecId,
  660. unitPrice: item.internalSellingPrice,
  661. quantity: item.quantity,
  662. bomSpecName: item.name,
  663. };
  664. });
  665. }
  666. }
  667. }
  668. formData.data.orderSkuList.push({
  669. wlnSkuName: SKU.name,
  670. skuId: row.skuId,
  671. code: row.code,
  672. name: row.name,
  673. skuSpecId: row.id,
  674. bomSpecId: row.bomSpecId,
  675. quantity: undefined,
  676. customProcessingFee: "",
  677. customProcessingType: "",
  678. lssueFee: "",
  679. deliveryMaterialsFee: "",
  680. packingLabor: "",
  681. managementFee: "",
  682. unitPrice: "",
  683. printType: 1,
  684. packageRemark: "",
  685. orderSkuBomList: orderSkuBomList,
  686. blueprint: row.designImgUrl,
  687. productionDocument: row.sharedFolder,
  688. });
  689. ElMessage({ message: "添加成功", type: "success" });
  690. };
  691. const rowIndex = ref(null);
  692. const openPackingFittings = ref(false);
  693. const clickPackingFittings = (index) => {
  694. rowIndex.value = index;
  695. openPackingFittings.value = true;
  696. };
  697. const clickDeletePackingFittings = (index, indexTwo) => {
  698. formData.data.orderSkuList[index].orderSkuBomList.splice(indexTwo, 1);
  699. };
  700. const selectPackingFittings = (data) => {
  701. if (formData.data.orderSkuList[rowIndex.value].orderSkuBomList && formData.data.orderSkuList[rowIndex.value].orderSkuBomList.length > 0) {
  702. let list = formData.data.orderSkuList[rowIndex.value].orderSkuBomList.filter((item) => item.bomSpecId === data.id);
  703. if (list && list.length > 0) {
  704. return ElMessage("包材配件已添加");
  705. }
  706. formData.data.orderSkuList[rowIndex.value].orderSkuBomList.push({
  707. bomSpecId: data.id,
  708. unitPrice: data.internalSellingPrice,
  709. quantity: undefined,
  710. bomSpecName: data.name,
  711. });
  712. } else {
  713. formData.data.orderSkuList[rowIndex.value].orderSkuBomList = [
  714. {
  715. bomSpecId: data.id,
  716. unitPrice: data.internalSellingPrice,
  717. quantity: undefined,
  718. bomSpecName: data.name,
  719. },
  720. ];
  721. }
  722. ElMessage({ message: "添加成功", type: "success" });
  723. };
  724. const changeQuantity = (index) => {
  725. if (formData.data.orderSkuList[index].quantity) {
  726. proxy
  727. .post("/orderInfo/getSkuSpecPrice", {
  728. skuSpecId: formData.data.orderSkuList[index].skuSpecId,
  729. quantity: formData.data.orderSkuList[index].quantity,
  730. random: proxy.random(),
  731. })
  732. .then((res) => {
  733. if (formData.data.orderSkuList[index].printType == 2 && res.customProcessingFee) {
  734. formData.data.orderSkuList[index].customProcessingFee = Number(Math.round(res.customProcessingFee * 2 * 100) / 100);
  735. } else {
  736. formData.data.orderSkuList[index].customProcessingFee = res.customProcessingFee;
  737. }
  738. formData.data.orderSkuList[index].customProcessingType = res.customProcessingType;
  739. formData.data.orderSkuList[index].deliveryMaterialsFee = res.deliveryMaterialsFee;
  740. formData.data.orderSkuList[index].lssueFee = res.lssueFee;
  741. formData.data.orderSkuList[index].packingLabor = res.packingLabor;
  742. formData.data.orderSkuList[index].managementFee = res.managementFee;
  743. formData.data.orderSkuList[index].unitPrice = res.unitPrice;
  744. });
  745. }
  746. };
  747. const cellStyleName = ({ column, columnIndex }) => {
  748. if (column.label === "操作" && columnIndex === 4) {
  749. return "vertical-align";
  750. }
  751. };
  752. const uploadData = ref({});
  753. const uploadFile = async (file) => {
  754. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  755. uploadData.value = res.uploadBody;
  756. file.id = res.id;
  757. file.fileName = res.fileName;
  758. file.fileUrl = res.fileUrl;
  759. return true;
  760. };
  761. const handleSuccess = (UploadFile, index) => {
  762. formData.data.orderSkuList[index].productionDocument = UploadFile.raw.fileUrl;
  763. };
  764. const uploadImgData = ref({});
  765. const uploadImgFile = async (file) => {
  766. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  767. uploadImgData.value = res.uploadBody;
  768. file.id = res.id;
  769. file.fileName = res.fileName;
  770. file.fileUrl = res.fileUrl;
  771. return true;
  772. };
  773. const handleImgSuccess = (UploadFile, index) => {
  774. formData.data.orderSkuList[index].blueprint = UploadFile.raw.fileUrl;
  775. };
  776. const computeQuantity = (index, indexSKU) => {
  777. let quantity = 0;
  778. if (formData.data.orderSkuList[index].quantity && formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity) {
  779. quantity = Number(
  780. Math.round(formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity * formData.data.orderSkuList[index].quantity * 100) / 100
  781. );
  782. }
  783. return quantity;
  784. };
  785. const computeMoney = (index, indexSKU) => {
  786. let money = 0;
  787. if (
  788. formData.data.orderSkuList[index].quantity &&
  789. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity &&
  790. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].unitPrice
  791. ) {
  792. money = Number(
  793. Math.round(
  794. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity *
  795. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].unitPrice *
  796. formData.data.orderSkuList[index].quantity *
  797. 100
  798. ) / 100
  799. );
  800. }
  801. return money;
  802. };
  803. const getSubtotal = (item) => {
  804. let money = 0;
  805. if (item.quantity) {
  806. money = Number(
  807. Math.round(
  808. (item.customProcessingFee + item.deliveryMaterialsFee + item.lssueFee + item.packingLabor + item.managementFee + item.unitPrice) * item.quantity * 100
  809. ) / 100
  810. );
  811. }
  812. return money;
  813. };
  814. const calculatedAmount = (label) => {
  815. let money = 0;
  816. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  817. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  818. if (formData.data.orderSkuList[i].quantity && formData.data.orderSkuList[i][label]) {
  819. money = Number(Math.round((money + formData.data.orderSkuList[i][label] * formData.data.orderSkuList[i].quantity) * 100) / 100);
  820. }
  821. }
  822. }
  823. return money;
  824. };
  825. const calculatedPackagingMaterialCost = () => {
  826. let money = 0;
  827. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  828. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  829. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  830. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  831. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity && formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  832. money = Number(
  833. Math.round(
  834. (money +
  835. formData.data.orderSkuList[i].orderSkuBomList[j].quantity *
  836. formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice *
  837. formData.data.orderSkuList[i].quantity) *
  838. 100
  839. ) / 100
  840. );
  841. }
  842. }
  843. }
  844. }
  845. }
  846. return money;
  847. };
  848. const calculatedTotalAmount = () => {
  849. let money = 0;
  850. money = Number(
  851. Math.round(
  852. (calculatedAmount("unitPrice") +
  853. calculatedAmount("customProcessingFee") +
  854. calculatedAmount("lssueFee") +
  855. calculatedAmount("deliveryMaterialsFee") +
  856. calculatedAmount("packingLabor") +
  857. calculatedAmount("managementFee") +
  858. calculatedPackagingMaterialCost()) *
  859. 100
  860. ) / 100
  861. );
  862. return money;
  863. };
  864. const fileList = ref([]);
  865. const uploadFileData = ref({});
  866. const beforeUpload = async (file) => {
  867. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  868. uploadFileData.value = res.uploadBody;
  869. file.id = res.id;
  870. file.fileName = res.fileName;
  871. file.fileUrl = res.fileUrl;
  872. file.uploadState = true;
  873. return true;
  874. };
  875. const onSuccessFile = (any, UploadFile) => {
  876. UploadFile.raw.uploadState = false;
  877. };
  878. const onPreviewFile = (file) => {
  879. window.open(file.raw.fileUrl, "_blank");
  880. };
  881. const uploadAdhesiveData = ref({});
  882. const uploadAdhesiveFile = async (file) => {
  883. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  884. uploadAdhesiveData.value = res.uploadBody;
  885. file.id = res.id;
  886. file.fileName = res.fileName;
  887. file.fileUrl = res.fileUrl;
  888. return true;
  889. };
  890. const handleAdhesiveSuccess = (UploadFile, index) => {
  891. formData.data.orderSkuList[index].selfAdhesiveStickerFile = {
  892. id: UploadFile.raw.id,
  893. fileName: UploadFile.raw.fileName,
  894. fileUrl: UploadFile.raw.fileUrl,
  895. };
  896. };
  897. const getFormData = () => {
  898. return proxy.deepClone(formData.data);
  899. };
  900. const handleSubmit = async (flag) => {
  901. if (flag) {
  902. return true;
  903. } else {
  904. let status = await proxy.$refs.submit.handleSubmit(() => {});
  905. if (status) {
  906. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  907. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  908. if (!formData.data.orderSkuList[i].blueprint) {
  909. ElMessage("请选择设计图");
  910. return false;
  911. }
  912. if (!formData.data.orderSkuList[i].productionDocument) {
  913. ElMessage("请选择生产文件");
  914. return false;
  915. }
  916. let packagingMaterialCost = 0;
  917. if (formData.data.orderSkuList[i].quantity) {
  918. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  919. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  920. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity && formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  921. packagingMaterialCost = Number(
  922. Math.round(
  923. (packagingMaterialCost +
  924. formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) *
  925. 100
  926. ) / 100
  927. );
  928. }
  929. }
  930. }
  931. }
  932. formData.data.orderSkuList[i].packagingMaterialCost = packagingMaterialCost;
  933. }
  934. formData.data.productTotalAmount = calculatedAmount("unitPrice");
  935. formData.data.customProcessingFee = calculatedAmount("customProcessingFee");
  936. formData.data.lssueFee = calculatedAmount("lssueFee");
  937. formData.data.deliveryMaterialsFee = calculatedAmount("deliveryMaterialsFee");
  938. formData.data.packingLabor = calculatedAmount("packingLabor");
  939. formData.data.managementFee = calculatedAmount("managementFee");
  940. formData.data.packagingMaterialCost = calculatedPackagingMaterialCost();
  941. formData.data.totalAmount = calculatedTotalAmount();
  942. if (fileList.value && fileList.value.length > 0) {
  943. for (let i = 0; i < fileList.value.length; i++) {
  944. if (fileList.value[i].raw.uploadState) {
  945. ElMessage("文件上传中,请稍后提交");
  946. return false;
  947. }
  948. }
  949. formData.data.fileList = fileList.value.map((item) => {
  950. return {
  951. id: item.raw.id,
  952. fileName: item.raw.fileName,
  953. fileUrl: item.raw.fileUrl,
  954. };
  955. });
  956. } else {
  957. formData.data.fileList = [];
  958. }
  959. } else {
  960. return ElMessage("请添加产品");
  961. }
  962. return true;
  963. } else {
  964. setTimeout(() => {
  965. const errorDiv = document.getElementsByClassName("is-error");
  966. errorDiv[0].scrollIntoView();
  967. }, 0);
  968. }
  969. return false;
  970. }
  971. };
  972. watch(
  973. () => props.queryData,
  974. (newValue) => {
  975. formOption.disabled = judgeStatus();
  976. if (props.queryData && ["10", "20", "30", "40"].includes(route.query.processType)) {
  977. formData.data = proxy.deepClone(newValue);
  978. if (route.query.id) {
  979. proxy.$refs.editor.changeHtml(formData.data.remark);
  980. }
  981. let list = [formData.data.id];
  982. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  983. list = list.concat(formData.data.orderSkuList.map((item) => item.id));
  984. proxy.post("/fileInfo/getList", { businessIdList: list }).then((fileObj) => {
  985. if (fileObj[formData.data.id] && fileObj[formData.data.id].length > 0) {
  986. let file = fileObj[formData.data.id].filter((item) => item.businessType == "0");
  987. if (file && file.length > 0) {
  988. fileList.value = file.map((item) => {
  989. return {
  990. raw: item,
  991. name: item.fileName,
  992. url: item.fileUrl,
  993. };
  994. });
  995. } else {
  996. fileList.value = [];
  997. }
  998. let outerBoxSelfAdhesiveStickerFile = fileObj[formData.data.id].filter((item) => item.businessType == "1");
  999. if (outerBoxSelfAdhesiveStickerFile && outerBoxSelfAdhesiveStickerFile.length > 0) {
  1000. formData.data.outerBoxSelfAdhesiveStickerFile = outerBoxSelfAdhesiveStickerFile[0];
  1001. } else {
  1002. formData.data.outerBoxSelfAdhesiveStickerFile = {};
  1003. }
  1004. }
  1005. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  1006. if (fileObj[formData.data.orderSkuList[i].id] && fileObj[formData.data.orderSkuList[i].id].length > 0) {
  1007. formData.data.orderSkuList[i].selfAdhesiveStickerFile = {
  1008. id: fileObj[formData.data.orderSkuList[i].id][0].id,
  1009. fileName: fileObj[formData.data.orderSkuList[i].id][0].fileName,
  1010. fileUrl: fileObj[formData.data.orderSkuList[i].id][0].fileUrl,
  1011. };
  1012. }
  1013. }
  1014. });
  1015. }
  1016. }
  1017. },
  1018. {
  1019. deep: true,
  1020. }
  1021. );
  1022. const saveShippingPackage = (data) => {
  1023. formData.data.orderPackageBomList = data.orderPackageBomList;
  1024. formData.data.outerBoxSelfAdhesiveStickerFile = data.outerBoxSelfAdhesiveStickerFile;
  1025. };
  1026. // 向父组件暴露
  1027. defineExpose({ getFormData, handleSubmit, saveShippingPackage });
  1028. </script>
  1029. <style lang="scss" scoped>
  1030. ::v-deep(.el-input-number .el-input__inner) {
  1031. text-align: left;
  1032. }
  1033. :deep(.el-dialog) {
  1034. margin-top: 10px !important;
  1035. margin-bottom: 10px !important;
  1036. }
  1037. :deep(.ql-editor) {
  1038. height: auto;
  1039. }
  1040. :deep(.el-table__cell) {
  1041. vertical-align: top;
  1042. }
  1043. :deep(.vertical-align) {
  1044. vertical-align: middle;
  1045. }
  1046. </style>