add.vue 37 KB

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