add.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <div style="padding: 8px; text-align: center" v-if="formData.data.code || formData.data.wlnCode">
  5. <span style="font-size: 18px; font-weight: 700">{{ formData.data.code }} </span>
  6. <span style="font-size: 18px; font-weight: 700" v-if="formData.data.wlnCode"> ({{ formData.data.wlnCode }})</span>
  7. </div>
  8. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  9. <template #deliveryAddress>
  10. <div style="width: 100%">
  11. <el-row>
  12. <el-col :span="3">
  13. <el-form-item label-width="0" prop="province" style="width: 100%">
  14. <el-input v-model="formData.data.province" placeholder="请输入省" />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="3">
  18. <el-form-item label-width="0" prop="city" style="width: 100%">
  19. <el-input v-model="formData.data.city" placeholder="请输入市" />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="3">
  23. <el-form-item label-width="0" prop="county" style="width: 100%">
  24. <el-input v-model="formData.data.county" placeholder="请输入区/县" />
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="11">
  28. <el-form-item label-width="0" prop="detailedAddress" style="width: 100%">
  29. <el-input v-model="formData.data.detailedAddress" placeholder="请输入详细地址" />
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="4">
  33. <el-form-item label-width="0" prop="postcode" style="width: 100%">
  34. <el-input v-model="formData.data.postcode" placeholder="请输入邮编" />
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. </div>
  39. </template>
  40. <template #consignee>
  41. <div style="width: 100%">
  42. <el-row>
  43. <el-col :span="6">
  44. <el-form-item label-width="0" prop="consignee" style="width: 100%">
  45. <el-input v-model="formData.data.consignee" placeholder="请输入联系人" />
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6">
  49. <el-form-item label-width="0" prop="consigneeNumber" style="width: 100%">
  50. <el-input v-model="formData.data.consigneeNumber" placeholder="请输入联系电话" />
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="6">
  54. <el-form-item label-width="0" prop="departmentId" style="width: 100%">
  55. <el-select v-model="formData.data.departmentId" placeholder="请选择事业部" clearable style="width: 100%">
  56. <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. </div>
  62. </template>
  63. <template #orderSkuList>
  64. <div style="width: 100%; padding: 0 20px">
  65. <div style="margin-bottom: 10px">
  66. <el-button type="primary" size="small" @click="clickAddProduct()">选择产品</el-button>
  67. </div>
  68. <el-collapse v-model="activeNames">
  69. <div v-for="(item, index) in formData.data.orderSkuList" :key="index" style="margin-bottom: 20px">
  70. <div style="border: 1px solid #edf0f5">
  71. <el-table :data="[item]" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  72. <el-table-column label="产品" width="300">
  73. <template #default="{ row }">
  74. <div style="width: 100%">
  75. <div style="line-height: 28px">
  76. <span style="color: black; font-weight: 700">商品名称: </span>
  77. <span>{{ item.wlnSkuName }}</span>
  78. </div>
  79. <div style="line-height: 28px">
  80. <span style="color: black; font-weight: 700">品号: </span>
  81. <span>{{ item.code }}</span>
  82. </div>
  83. <div style="line-height: 28px; word-break: break-all">
  84. <span style="color: black; font-weight: 700">品名: </span>
  85. <span>{{ item.name }}</span>
  86. </div>
  87. <div style="line-height: 28px; display: flex">
  88. <span style="width: 37px; color: black; font-weight: 700">数量: </span>
  89. <el-form-item
  90. :prop="'orderSkuList.' + index + '.quantity'"
  91. :rules="rules.quantity"
  92. :inline-message="true"
  93. style="width: calc(100% - 37px)">
  94. <el-input-number
  95. onmousewheel="return false;"
  96. v-model="row.quantity"
  97. placeholder="数量"
  98. style="width: 100%"
  99. :controls="false"
  100. :min="0"
  101. :precision="0"
  102. @change="changeQuantity(index)" />
  103. </el-form-item>
  104. </div>
  105. <div style="line-height: 28px">
  106. <span style="color: black; font-weight: 700">加工费: </span>
  107. <span>{{ item.customProcessingFee }}</span>
  108. </div>
  109. <div style="line-height: 28px">
  110. <span style="color: black; font-weight: 700">代发费: </span>
  111. <span>{{ item.lssueFee }}</span>
  112. </div>
  113. <div style="line-height: 28px">
  114. <span style="color: black; font-weight: 700">快递包材费: </span>
  115. <span>{{ item.deliveryMaterialsFee }}</span>
  116. </div>
  117. <div style="line-height: 28px">
  118. <span style="color: black; font-weight: 700">包装人工费: </span>
  119. <span>{{ item.packingLabor }}</span>
  120. </div>
  121. <div style="line-height: 28px">
  122. <span style="color: black; font-weight: 700">单价: </span>
  123. <span>{{ item.unitPrice }}</span>
  124. </div>
  125. <div style="line-height: 28px">
  126. <span style="color: black; font-weight: 700">小计: </span>
  127. <span>{{ item.subtotal }}</span>
  128. </div>
  129. <div style="line-height: 28px">
  130. <span style="width: 37px; color: black; font-weight: 700">打印: </span>
  131. <el-form-item
  132. :prop="'orderSkuList.' + index + '.printType'"
  133. :rules="rules.printType"
  134. :inline-message="true"
  135. style="width: calc(100% - 37px)">
  136. <el-radio-group v-model="item.printType">
  137. <el-radio v-for="(itemType, index) in printType" :key="index" :label="itemType.dictKey">{{ itemType.dictValue }}</el-radio>
  138. </el-radio-group>
  139. </el-form-item>
  140. </div>
  141. </div>
  142. </template>
  143. </el-table-column>
  144. <el-table-column label="图稿(设计图)" width="180">
  145. <template #default="{ row }">
  146. <el-form-item :prop="'orderSkuList.' + index + '.productImgUrl'">
  147. <el-upload
  148. class="avatar-uploader"
  149. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  150. :data="uploadProductData"
  151. :show-file-list="false"
  152. :on-success="
  153. (response, uploadFile) => {
  154. return handleProductSuccess(uploadFile, index);
  155. }
  156. "
  157. :before-upload="uploadProductFile">
  158. <el-image v-if="row.productImgUrl" :src="row.productImgUrl" fit="scale-down" class="avatar" />
  159. <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
  160. </el-upload>
  161. </el-form-item>
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="图稿(生产文件)" width="320">
  165. <template #default="{ row }">
  166. <div style="color: black">共享文件夹路径(点击下方链接并上传文件):</div>
  167. </template>
  168. </el-table-column>
  169. <el-table-column label="包材配件/单品" min-width="400">
  170. <template #default="{ row }">
  171. <div style="width: 100%">
  172. <div style="margin-bottom: 10px">
  173. <el-button type="primary" @click="clickPackingFittings(index)">选择包材配件</el-button>
  174. </div>
  175. <el-table :data="row.orderSkuBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  176. <el-table-column label="单价¥" width="80">
  177. <template #default="props">
  178. {{ moneyFormat(props.row.unitPrice, 2) }}
  179. </template>
  180. </el-table-column>
  181. <el-table-column label="数量" width="100">
  182. <template #default="props">
  183. <el-form-item
  184. :prop="'orderSkuList.' + index + '.orderSkuBomList.' + props.$index + '.quantity'"
  185. :rules="rules.quantity"
  186. :inline-message="true"
  187. style="width: 100%">
  188. <el-input-number
  189. onmousewheel="return false;"
  190. v-model="props.row.quantity"
  191. placeholder="数量"
  192. style="width: 100%"
  193. :controls="false"
  194. :min="0"
  195. @change="changeBOMQuantity(index)" />
  196. </el-form-item>
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="名称" prop="name" min-width="150" />
  200. <el-table-column label="总量" prop="allQuantity" width="80" />
  201. <el-table-column label="小计¥" width="100">
  202. <template #default="props">
  203. {{ moneyFormat(props.row.allUnitPrice, 2) }}
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="操作" align="center" fixed="right" width="60">
  207. <template #default="props">
  208. <el-button type="danger" @click="clickDeletePackingFittings(index, props.$index)" text>删除</el-button>
  209. </template>
  210. </el-table-column>
  211. </el-table>
  212. </div>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="操作" align="center" fixed="right" width="60">
  216. <template #default="{}">
  217. <el-button type="primary" @click="clickDelete(index)" text>删除</el-button>
  218. </template>
  219. </el-table-column>
  220. </el-table>
  221. <el-collapse-item :name="index">
  222. <template #title>
  223. <span>包装</span>
  224. </template>
  225. <div style="display: flex; padding: 8px 10px 0px">
  226. <div style="flex: 1; padding: 0px 10px">
  227. <div>包装要求:</div>
  228. <div v-if="route.query && route.query.detailId">
  229. <div v-html="getStyle(item.packageRemark)"></div>
  230. </div>
  231. <Editor
  232. v-else
  233. :value="item.packageRemark"
  234. @updateValue="
  235. (val) => {
  236. return updatePackageRemark(val, index);
  237. }
  238. "
  239. :ref="'editor_' + index" />
  240. </div>
  241. </div>
  242. </el-collapse-item>
  243. </div>
  244. </div>
  245. </el-collapse>
  246. </div>
  247. </template>
  248. <template #deliveryTime>
  249. <div style="width: 100%">
  250. <el-date-picker
  251. v-model="formData.data.deliveryTime"
  252. type="datetime"
  253. placeholder="请选择交货日期"
  254. value-format="YYYY-MM-DD HH:mm:ss"
  255. style="width: 100%" />
  256. </div>
  257. </template>
  258. <template #totalMonet>
  259. <div style="width: 100%; margin-left: 30px">
  260. <div>
  261. <span style="font-weight: 700; color: #6c88f1">产品总金额: ¥{{ moneyFormat(formData.data.productTotalAmount, 2) }}</span>
  262. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">定制加工费: ¥{{ moneyFormat(formData.data.customProcessingFee, 2) }}</span>
  263. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">代发费: ¥{{ moneyFormat(formData.data.lssueFee, 2) }}</span>
  264. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">快递包材费: ¥{{ moneyFormat(formData.data.deliveryMaterialsFee, 2) }}</span>
  265. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">包装人工费: ¥{{ moneyFormat(formData.data.packingLabor, 2) }}</span>
  266. <span style="font-weight: 700; color: #6c88f1; margin-left: 40px">包材费: ¥{{ moneyFormat(formData.data.packagingMaterialCost, 2) }}</span>
  267. </div>
  268. <div style="padding: 8px 0 0 0">
  269. <span style="font-weight: 700; color: red">订单总金额(含税): ¥{{ moneyFormat(formData.data.totalAmount, 2) }}</span>
  270. </div>
  271. </div>
  272. </template>
  273. <template #attachments>
  274. <div style="width: 100%">
  275. <el-upload
  276. v-model:fileList="fileList"
  277. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  278. :data="uploadData"
  279. multiple
  280. :before-upload="uploadFile"
  281. :on-success="handleSuccess"
  282. :on-preview="onPreviewFile">
  283. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
  284. </el-upload>
  285. </div>
  286. </template>
  287. <template #remark>
  288. <div style="width: 100%">
  289. <div v-if="route.query && route.query.detailId">
  290. <div v-html="getStyle(formData.data.remark)"></div>
  291. </div>
  292. <Editor v-else :value="formData.data.remark" @updateValue="updateValue" ref="editor" />
  293. </div>
  294. </template>
  295. </byForm>
  296. <div style="width: 100%; text-align: center; margin: 10px">
  297. <el-button @click="clickCancel()" v-if="route.query && route.query.detailId" size="large">关 闭</el-button>
  298. <el-button @click="clickCancel()" v-if="!(route.query && route.query.detailId)" size="large">取 消</el-button>
  299. <el-button @click="submitForm('0')" v-if="!(route.query && route.query.detailId)" size="large" v-preReClick>暂 存</el-button>
  300. <el-button type="primary" @click="submitForm('10')" v-if="!(route.query && route.query.detailId)" size="large" v-preReClick>确 定</el-button>
  301. </div>
  302. </el-card>
  303. <el-dialog title="选择产品" v-if="openProduct" v-model="openProduct" width="90%">
  304. <SelectProduct :selectStatus="true" @selectProduct="selectProduct"></SelectProduct>
  305. <template #footer>
  306. <el-button @click="openProduct = false" size="large">关 闭</el-button>
  307. </template>
  308. </el-dialog>
  309. <el-dialog title="选择包材配件" v-if="openPackingFittings" v-model="openPackingFittings" width="90%">
  310. <SelectBOM :selectStatus="true" :bomClassifyIdList="[2, 3]" @selectBOM="selectPackingFittings"></SelectBOM>
  311. <template #footer>
  312. <el-button @click="openPackingFittings = false" size="large">关 闭</el-button>
  313. </template>
  314. </el-dialog>
  315. </div>
  316. </template>
  317. <script setup>
  318. import byForm from "@/components/byForm/index";
  319. import { ElMessage } from "element-plus";
  320. import Editor from "@/components/Editor/index.vue";
  321. import { useRouter, useRoute } from "vue-router";
  322. import SelectProduct from "@/views/group/product/management/index";
  323. import SelectBOM from "@/views/group/BOM/management/index";
  324. import useTagsViewStore from "@/store/modules/tagsView";
  325. const { proxy } = getCurrentInstance();
  326. const router = useRouter();
  327. const route = useRoute();
  328. const submit = ref(null);
  329. const departmentList = ref([]);
  330. const activeNames = ref([]);
  331. const formOption = reactive({
  332. inline: true,
  333. labelWidth: "120px",
  334. itemWidth: 100,
  335. rules: [],
  336. labelPosition: "right",
  337. });
  338. const formData = reactive({
  339. data: {
  340. remark: "",
  341. fileList: [],
  342. orderSkuList: [],
  343. },
  344. });
  345. const formConfig = computed(() => {
  346. return [
  347. {
  348. type: "title",
  349. title: "地址",
  350. label: "",
  351. },
  352. {
  353. type: "slot",
  354. slotName: "deliveryAddress",
  355. label: "收货地址",
  356. },
  357. {
  358. type: "slot",
  359. slotName: "consignee",
  360. label: "收货人",
  361. },
  362. {
  363. type: "title",
  364. title: "产品",
  365. label: "",
  366. },
  367. {
  368. type: "slot",
  369. prop: "orderSkuList",
  370. slotName: "orderSkuList",
  371. },
  372. {
  373. type: "title",
  374. title: "贸易",
  375. label: "",
  376. },
  377. {
  378. type: "slot",
  379. prop: "deliveryTime",
  380. slotName: "deliveryTime",
  381. label: "交货时间",
  382. itemWidth: 25,
  383. },
  384. {
  385. type: "select",
  386. label: "选择快递",
  387. prop: "expressDeliveryId",
  388. data: [],
  389. itemWidth: 25,
  390. clearable: true,
  391. },
  392. {
  393. type: "select",
  394. label: "电商平台",
  395. prop: "commercePlatform",
  396. data: proxy.useUserStore().allDict["commerce_platform"],
  397. itemWidth: 25,
  398. clearable: true,
  399. },
  400. {
  401. type: "title",
  402. title: "总计",
  403. label: "",
  404. },
  405. {
  406. type: "slot",
  407. prop: "totalMonet",
  408. slotName: "totalMonet",
  409. },
  410. {
  411. type: "title",
  412. title: "附件",
  413. label: "",
  414. },
  415. {
  416. type: "slot",
  417. slotName: "attachments",
  418. label: "附件",
  419. },
  420. {
  421. type: "title",
  422. title: "订单备注",
  423. label: "",
  424. },
  425. {
  426. type: "slot",
  427. slotName: "remark",
  428. },
  429. ];
  430. });
  431. const rules = ref({
  432. province: [{ required: true, message: "请输入省", trigger: "blur" }],
  433. detailedAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  434. consignee: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  435. consigneeNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  436. deliveryTime: [{ required: true, message: "请选择交货时间", trigger: "change" }],
  437. // expressDeliveryId: [{ required: true, message: "请选择快递", trigger: "change" }],
  438. commercePlatform: [{ required: true, message: "请选择电商平台", trigger: "change" }],
  439. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  440. });
  441. const getDepartment = () => {
  442. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  443. if (res.rows && res.rows.length > 0) {
  444. departmentList.value = res.rows.map((item) => {
  445. return {
  446. dictKey: item.id,
  447. dictValue: item.name,
  448. };
  449. });
  450. }
  451. });
  452. };
  453. getDepartment();
  454. const uploadProductData = ref({});
  455. const uploadProductFile = async (file) => {
  456. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  457. uploadProductData.value = res.uploadBody;
  458. file.id = res.id;
  459. file.fileName = res.fileName;
  460. file.fileUrl = res.fileUrl;
  461. return true;
  462. };
  463. const handleProductSuccess = (uploadFile, index) => {
  464. formData.data.orderSkuList[index].productImgUrl = uploadFile.raw.fileUrl;
  465. };
  466. const uploadData = ref({});
  467. const fileList = ref([]);
  468. const uploadFile = async (file) => {
  469. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  470. uploadData.value = res.uploadBody;
  471. file.id = res.id;
  472. file.fileName = res.fileName;
  473. file.fileUrl = res.fileUrl;
  474. file.uploadState = true;
  475. return true;
  476. };
  477. const handleSuccess = (any, UploadFile) => {
  478. UploadFile.raw.uploadState = false;
  479. };
  480. const onPreviewFile = (file) => {
  481. window.open(file.raw.fileUrl, "_blank");
  482. };
  483. const updatePackageRemark = (val, index) => {
  484. formData.data.orderSkuList[index].packageRemark = val;
  485. };
  486. const clickDelete = (index) => {
  487. formData.data.orderSkuList.splice(index, 1);
  488. calculatedAmount();
  489. };
  490. const updateValue = (val) => {
  491. formData.data.remark = val;
  492. };
  493. const submitForm = (status) => {
  494. submit.value.handleSubmit(() => {
  495. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  496. if (fileList.value && fileList.value.length > 0) {
  497. for (let i = 0; i < fileList.value.length; i++) {
  498. if (fileList.value[i].raw.uploadState) {
  499. return ElMessage("文件上传中,请稍后提交");
  500. }
  501. }
  502. formData.data.fileList = fileList.value.map((item) => {
  503. return {
  504. id: item.raw.id,
  505. fileName: item.raw.fileName,
  506. fileUrl: item.raw.fileUrl,
  507. };
  508. });
  509. } else {
  510. formData.data.fileList = [];
  511. }
  512. let type = "add";
  513. if (formData.data.id) {
  514. type = "edit";
  515. }
  516. formData.data.status = status;
  517. proxy.post("/orderInfo/" + type, formData.data).then(() => {
  518. ElMessage({
  519. message: type == "add" ? "添加成功" : "编辑成功",
  520. type: "success",
  521. });
  522. clickCancel();
  523. });
  524. } else {
  525. return ElMessage("请添加产品");
  526. }
  527. });
  528. };
  529. const clickCancel = () => {
  530. const useTagsStore = useTagsViewStore();
  531. useTagsStore.delVisitedView(router.currentRoute.value);
  532. if (route.query && route.query.orderInquiry) {
  533. router.replace({
  534. path: "/production/schedule/order-inquiry",
  535. });
  536. } else {
  537. router.replace({
  538. path: "/group/order/order-management",
  539. });
  540. }
  541. };
  542. onMounted(() => {
  543. if (route.query && (route.query.id || route.query.detailId)) {
  544. useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
  545. if (item.query && item.query.random === route.query.random) {
  546. return {
  547. ...item,
  548. name: route.query.text,
  549. title: route.query.text,
  550. };
  551. } else {
  552. return {
  553. ...item,
  554. };
  555. }
  556. });
  557. getOrderDetail({ id: route.query.id || route.query.detailId });
  558. }
  559. });
  560. const getOrderDetail = (parameter) => {
  561. proxy.post("/orderInfo/detail", parameter).then((res) => {
  562. formData.data = res;
  563. if (route.query.id) {
  564. proxy.$refs.editor.changeHtml(formData.data.remark);
  565. }
  566. if (route.query.detailId) {
  567. let allIndex = [];
  568. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  569. allIndex.push(i);
  570. }
  571. activeNames.value = allIndex;
  572. formOption.disabled = true;
  573. }
  574. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  575. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  576. let subtotal = 0;
  577. let packagingMaterialCost = 0;
  578. if (formData.data.orderSkuList[i].quantity) {
  579. subtotal = Number(
  580. Math.round(
  581. (formData.data.orderSkuList[i].customProcessingFee +
  582. formData.data.orderSkuList[i].deliveryMaterialsFee +
  583. formData.data.orderSkuList[i].lssueFee +
  584. formData.data.orderSkuList[i].packingLabor +
  585. formData.data.orderSkuList[i].unitPrice) *
  586. formData.data.orderSkuList[i].quantity *
  587. 100
  588. ) / 100
  589. );
  590. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  591. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  592. let allQuantity = 0;
  593. let allUnitPrice = 0;
  594. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity) {
  595. allQuantity = Number(
  596. Math.round(formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].quantity * 100) / 100
  597. );
  598. if (formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  599. allUnitPrice = Number(
  600. Math.round(
  601. formData.data.orderSkuList[i].orderSkuBomList[j].quantity *
  602. formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice *
  603. formData.data.orderSkuList[i].quantity *
  604. 100
  605. ) / 100
  606. );
  607. packagingMaterialCost = Number(
  608. Math.round(
  609. (packagingMaterialCost +
  610. formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) *
  611. 100
  612. ) / 100
  613. );
  614. }
  615. }
  616. formData.data.orderSkuList[i].orderSkuBomList[j].allQuantity = allQuantity;
  617. formData.data.orderSkuList[i].orderSkuBomList[j].allUnitPrice = allUnitPrice;
  618. }
  619. }
  620. }
  621. formData.data.orderSkuList[i].subtotal = subtotal;
  622. formData.data.orderSkuList[i].packagingMaterialCost = packagingMaterialCost;
  623. }
  624. }
  625. let list = [res.id];
  626. if (res.orderSkuList && res.orderSkuList.length > 0) {
  627. list = list.concat(res.orderSkuList.map((item) => item.id));
  628. }
  629. proxy.post("/fileInfo/getList", { businessIdList: list }).then((fileObj) => {
  630. if (fileObj) {
  631. if (fileObj[res.id] && fileObj[res.id].length > 0) {
  632. fileList.value = fileObj[res.id].map((item) => {
  633. return {
  634. raw: item,
  635. name: item.fileName,
  636. url: item.fileUrl,
  637. };
  638. });
  639. }
  640. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  641. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  642. if (fileObj[formData.data.orderSkuList[i].id] && fileObj[formData.data.orderSkuList[i].id].length > 0) {
  643. formData.data.orderSkuList[i].productImgUrl = fileObj[formData.data.orderSkuList[i].id][0];
  644. }
  645. }
  646. }
  647. }
  648. });
  649. });
  650. };
  651. const getStyle = (text) => {
  652. if (text) {
  653. return text.replace(/\n|\r\n/g, "<br>");
  654. } else {
  655. return "";
  656. }
  657. };
  658. const openProduct = ref(false);
  659. const clickAddProduct = () => {
  660. openProduct.value = true;
  661. };
  662. const printType = ref([
  663. {
  664. dictKey: "1",
  665. dictValue: "单面",
  666. },
  667. {
  668. dictKey: "2",
  669. dictValue: "双面",
  670. },
  671. ]);
  672. const selectProduct = (row, bom) => {
  673. if (row.id) {
  674. let list = formData.data.orderSkuList.filter((item) => item.skuSpecId === row.id);
  675. if (list && list.length > 0) {
  676. return ElMessage("该产品已添加");
  677. }
  678. formData.data.orderSkuList.push({
  679. wlnSkuName: bom.name,
  680. skuId: row.skuId,
  681. code: row.code,
  682. name: row.name,
  683. skuSpecId: row.id,
  684. quantity: undefined,
  685. customProcessingFee: "",
  686. lssueFee: "",
  687. deliveryMaterialsFee: "",
  688. packingLabor: "",
  689. unitPrice: "",
  690. printType: "1",
  691. packageRemark: "",
  692. subtotal: "",
  693. orderSkuBomList: [],
  694. });
  695. ElMessage({ message: "添加成功", type: "success" });
  696. } else {
  697. ElMessage("添加失败");
  698. }
  699. };
  700. const rowIndex = ref(null);
  701. const openPackingFittings = ref(false);
  702. const clickPackingFittings = (index) => {
  703. rowIndex.value = index;
  704. openPackingFittings.value = true;
  705. };
  706. const clickDeletePackingFittings = (index, indexTwo) => {
  707. formData.data.orderSkuList[index].orderSkuBomList.splice(indexTwo, 1);
  708. calculatedAmount();
  709. };
  710. const selectPackingFittings = (data) => {
  711. if (formData.data.orderSkuList[rowIndex.value].orderSkuBomList && formData.data.orderSkuList[rowIndex.value].orderSkuBomList.length > 0) {
  712. let list = formData.data.orderSkuList[rowIndex.value].orderSkuBomList.filter((item) => item.bomSpecId === data.id);
  713. if (list && list.length > 0) {
  714. return ElMessage("包材配件已添加");
  715. }
  716. formData.data.orderSkuList[rowIndex.value].orderSkuBomList.push({
  717. bomSpecId: data.id,
  718. unitPrice: data.costPrice,
  719. quantity: undefined,
  720. name: data.name,
  721. allQuantity: 0,
  722. allUnitPrice: 0,
  723. });
  724. } else {
  725. formData.data.orderSkuList[rowIndex.value].orderSkuBomList = [
  726. {
  727. bomSpecId: data.id,
  728. unitPrice: data.costPrice,
  729. quantity: undefined,
  730. name: data.name,
  731. allQuantity: 0,
  732. allUnitPrice: 0,
  733. },
  734. ];
  735. }
  736. ElMessage({ message: "添加成功", type: "success" });
  737. };
  738. const changeQuantity = (index) => {
  739. if (formData.data.orderSkuList[index].quantity) {
  740. proxy
  741. .post("/orderInfo/getSkuSpecPrice", { skuSpecId: formData.data.orderSkuList[index].skuSpecId, quantity: formData.data.orderSkuList[index].quantity })
  742. .then((res) => {
  743. formData.data.orderSkuList[index].customProcessingFee = res.customProcessingFee;
  744. formData.data.orderSkuList[index].deliveryMaterialsFee = res.deliveryMaterialsFee;
  745. formData.data.orderSkuList[index].lssueFee = res.lssueFee;
  746. formData.data.orderSkuList[index].packingLabor = res.packingLabor;
  747. formData.data.orderSkuList[index].unitPrice = res.unitPrice;
  748. formData.data.orderSkuList[index].subtotal = Number(
  749. Math.round(
  750. (res.customProcessingFee + res.deliveryMaterialsFee + res.lssueFee + res.packingLabor + res.unitPrice) *
  751. formData.data.orderSkuList[index].quantity *
  752. 100
  753. ) / 100
  754. );
  755. changeBOMQuantity(index);
  756. });
  757. }
  758. };
  759. const changeBOMQuantity = (index) => {
  760. if (formData.data.orderSkuList[index].orderSkuBomList && formData.data.orderSkuList[index].orderSkuBomList.length > 0) {
  761. if (formData.data.orderSkuList[index].quantity) {
  762. formData.data.orderSkuList[index].orderSkuBomList = formData.data.orderSkuList[index].orderSkuBomList.map((item) => {
  763. let allQuantity = 0;
  764. let allUnitPrice = 0;
  765. if (item.quantity) {
  766. allQuantity = Number(Math.round(Number(item.quantity) * Number(formData.data.orderSkuList[index].quantity)));
  767. }
  768. if (item.unitPrice) {
  769. allUnitPrice = Number(Math.round(Number(item.unitPrice) * Number(allQuantity) * 100) / 100);
  770. }
  771. return {
  772. ...item,
  773. allQuantity: allQuantity,
  774. allUnitPrice: allUnitPrice,
  775. };
  776. });
  777. } else {
  778. formData.data.orderSkuList[index].orderSkuBomList = formData.data.orderSkuList[index].orderSkuBomList.map((item) => {
  779. return {
  780. ...item,
  781. allQuantity: 0,
  782. allUnitPrice: 0,
  783. };
  784. });
  785. }
  786. }
  787. calculatedAmount();
  788. };
  789. const calculatedAmount = () => {
  790. let productTotalAmount = 0;
  791. let customProcessingFee = 0;
  792. let lssueFee = 0;
  793. let deliveryMaterialsFee = 0;
  794. let packingLabor = 0;
  795. let packagingMaterialCost = 0;
  796. let totalAmount = 0;
  797. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  798. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  799. if (formData.data.orderSkuList[i].quantity) {
  800. if (formData.data.orderSkuList[i].customProcessingFee) {
  801. customProcessingFee = Number(
  802. Math.round((customProcessingFee + formData.data.orderSkuList[i].customProcessingFee * formData.data.orderSkuList[i].quantity) * 100) / 100
  803. );
  804. }
  805. if (formData.data.orderSkuList[i].lssueFee) {
  806. lssueFee = Number(Math.round((lssueFee + formData.data.orderSkuList[i].lssueFee * formData.data.orderSkuList[i].quantity) * 100) / 100);
  807. }
  808. if (formData.data.orderSkuList[i].deliveryMaterialsFee) {
  809. deliveryMaterialsFee = Number(
  810. Math.round((deliveryMaterialsFee + formData.data.orderSkuList[i].deliveryMaterialsFee * formData.data.orderSkuList[i].quantity) * 100) / 100
  811. );
  812. }
  813. if (formData.data.orderSkuList[i].packingLabor) {
  814. packingLabor = Number(Math.round((packingLabor + formData.data.orderSkuList[i].packingLabor * formData.data.orderSkuList[i].quantity) * 100) / 100);
  815. }
  816. if (formData.data.orderSkuList[i].unitPrice) {
  817. productTotalAmount = Number(
  818. Math.round((productTotalAmount + formData.data.orderSkuList[i].unitPrice * formData.data.orderSkuList[i].quantity) * 100) / 100
  819. );
  820. }
  821. let money = 0;
  822. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  823. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  824. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity && formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  825. packagingMaterialCost = Number(
  826. Math.round(
  827. (packagingMaterialCost +
  828. formData.data.orderSkuList[i].orderSkuBomList[j].quantity *
  829. formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice *
  830. formData.data.orderSkuList[i].quantity) *
  831. 100
  832. ) / 100
  833. );
  834. money = Number(
  835. Math.round(
  836. (money + formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) * 100
  837. ) / 100
  838. );
  839. }
  840. }
  841. }
  842. formData.data.orderSkuList[i].packagingMaterialCost = money;
  843. }
  844. }
  845. }
  846. formData.data.productTotalAmount = productTotalAmount;
  847. formData.data.customProcessingFee = customProcessingFee;
  848. formData.data.lssueFee = lssueFee;
  849. formData.data.deliveryMaterialsFee = deliveryMaterialsFee;
  850. formData.data.packingLabor = packingLabor;
  851. formData.data.packagingMaterialCost = packagingMaterialCost;
  852. totalAmount = Number(
  853. Math.round((productTotalAmount + customProcessingFee + lssueFee + deliveryMaterialsFee + packingLabor + packagingMaterialCost) * 100) / 100
  854. );
  855. formData.data.totalAmount = totalAmount;
  856. };
  857. </script>
  858. <style lang="scss" scoped>
  859. ::v-deep(.el-input-number .el-input__inner) {
  860. text-align: left;
  861. }
  862. :deep(.el-dialog) {
  863. margin-top: 10px !important;
  864. margin-bottom: 10px !important;
  865. }
  866. :deep(.ql-editor) {
  867. height: auto;
  868. }
  869. :deep(.el-collapse-item__header) {
  870. justify-content: center;
  871. }
  872. :deep(.el-collapse-item__arrow) {
  873. margin: 0;
  874. }
  875. .avatar-uploader .avatar {
  876. width: 148px;
  877. height: 148px;
  878. display: block;
  879. background-color: black;
  880. }
  881. .avatar-uploader .el-upload {
  882. border: 1px dashed var(--el-border-color);
  883. border-radius: 6px;
  884. cursor: pointer;
  885. position: relative;
  886. overflow: hidden;
  887. transition: var(--el-transition-duration-fast);
  888. }
  889. .avatar-uploader .el-upload:hover {
  890. border-color: var(--el-color-primary);
  891. }
  892. .el-icon.avatar-uploader-icon {
  893. font-size: 28px;
  894. color: #8c939d;
  895. width: 148px;
  896. height: 148px;
  897. text-align: center;
  898. border: 1px dashed var(--el-border-color);
  899. }
  900. :deep(.el-table__cell) {
  901. vertical-align: top;
  902. }
  903. </style>