add.vue 39 KB

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