add.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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 #attachments>
  324. <div style="width: 100%">
  325. <el-upload
  326. v-model:fileList="fileList"
  327. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  328. :data="uploadFileData"
  329. multiple
  330. :before-upload="beforeUpload"
  331. :on-success="onSuccessFile"
  332. :on-preview="onPreviewFile">
  333. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
  334. </el-upload>
  335. </div>
  336. </template>
  337. <template #remark>
  338. <div style="width: 100%">
  339. <div style="margin: 0 2vw" v-if="route.query && route.query.detailId">
  340. <div v-html="getStyle(formData.data.remark)"></div>
  341. </div>
  342. <Editor v-else :value="formData.data.remark" @updateValue="updateValue" ref="editor" />
  343. </div>
  344. </template>
  345. </byForm>
  346. <div style="text-align: center; margin: 10px">
  347. <el-button @click="clickCancel()" v-if="route.query && route.query.detailId" size="large">关 闭</el-button>
  348. <el-button @click="clickCancel()" v-if="!(route.query && route.query.detailId)" size="large">取 消</el-button>
  349. <el-button @click="submitForm('0')" v-if="!(route.query && route.query.detailId)" size="large" v-preReClick>暂 存</el-button>
  350. <el-button type="primary" @click="submitForm('20')" v-if="!(route.query && route.query.detailId)" size="large" v-preReClick>提 交</el-button>
  351. </div>
  352. </el-card>
  353. <el-dialog title="选择产品" v-if="openProduct" v-model="openProduct" width="90%">
  354. <SelectProduct :selectStatus="true" :type="'null'" @selectProduct="selectProduct"></SelectProduct>
  355. <template #footer>
  356. <el-button @click="openProduct = false" size="large">关 闭</el-button>
  357. </template>
  358. </el-dialog>
  359. <el-dialog title="选择包材配件" v-if="openPackingFittings" v-model="openPackingFittings" width="90%">
  360. <SelectBOM :selectStatus="true" :bomClassifyIdList="[2, 3]" @selectBOM="selectPackingFittings"></SelectBOM>
  361. <template #footer>
  362. <el-button @click="openPackingFittings = false" size="large">关 闭</el-button>
  363. </template>
  364. </el-dialog>
  365. <el-dialog title="选择图稿文件" v-if="openDrawingFile" v-model="openDrawingFile" width="70%">
  366. <SelectPicture @selectPic="selectPic"></SelectPicture>
  367. <template #footer>
  368. <el-button @click="openDrawingFile = false" size="large">关 闭</el-button>
  369. </template>
  370. </el-dialog>
  371. </div>
  372. </template>
  373. <script setup>
  374. import byForm from "/src/components/byForm/index";
  375. import { ElMessage } from "element-plus";
  376. import Editor from "/src/components/Editor/index.vue";
  377. import { useRouter, useRoute } from "vue-router";
  378. import SelectProduct from "/src/views/group/product/management/index";
  379. import SelectBOM from "/src/views/group/BOM/management/index";
  380. import useTagsViewStore from "/src/store/modules/tagsView";
  381. import SelectPicture from "/src/components/select-picture/index.vue";
  382. import refreshStore from "/src/store/modules/refresh";
  383. const { proxy } = getCurrentInstance();
  384. const router = useRouter();
  385. const route = useRoute();
  386. const submit = ref(null);
  387. const departmentList = ref([]);
  388. const activeNames = ref([]);
  389. const formOption = reactive({
  390. inline: true,
  391. labelWidth: "120px",
  392. itemWidth: 100,
  393. rules: [],
  394. labelPosition: "right",
  395. });
  396. const formData = reactive({
  397. data: {
  398. remark: "",
  399. orderSkuList: [],
  400. fileList: [],
  401. },
  402. });
  403. const formConfig = computed(() => {
  404. return [
  405. {
  406. type: "title",
  407. title: "产品",
  408. label: "",
  409. },
  410. {
  411. type: "slot",
  412. prop: "orderSkuList",
  413. slotName: "orderSkuList",
  414. },
  415. route.query && route.query.detailId
  416. ? {}
  417. : {
  418. type: "title",
  419. title: "地址",
  420. label: "",
  421. },
  422. route.query && route.query.detailId
  423. ? {}
  424. : {
  425. type: "slot",
  426. slotName: "deliveryAddress",
  427. label: "收货地址",
  428. },
  429. route.query && route.query.detailId
  430. ? {}
  431. : {
  432. type: "slot",
  433. slotName: "consignee",
  434. label: "收货人",
  435. },
  436. {
  437. type: "title",
  438. title: "贸易",
  439. label: "",
  440. },
  441. {
  442. type: "slot",
  443. prop: "deliveryTime",
  444. slotName: "deliveryTime",
  445. label: "交货时间",
  446. itemWidth: 25,
  447. },
  448. {
  449. type: "select",
  450. label: "选择快递",
  451. prop: "expressDeliveryId",
  452. data: [],
  453. itemWidth: 25,
  454. clearable: true,
  455. },
  456. {
  457. type: "select",
  458. label: "店铺来源",
  459. prop: "sourcePlatform",
  460. data: proxy.useUserStore().allDict["source_platform"],
  461. itemWidth: 25,
  462. clearable: true,
  463. },
  464. {
  465. type: "select",
  466. label: "店铺名称",
  467. prop: "shopName",
  468. data: proxy.useUserStore().allDict["shop_name"],
  469. itemWidth: 25,
  470. clearable: true,
  471. },
  472. {
  473. type: "title",
  474. title: "总计",
  475. label: "",
  476. },
  477. {
  478. type: "slot",
  479. prop: "totalMonet",
  480. slotName: "totalMonet",
  481. },
  482. {
  483. type: "title",
  484. title: "附件",
  485. label: "",
  486. },
  487. {
  488. type: "slot",
  489. slotName: "attachments",
  490. label: "附件",
  491. },
  492. {
  493. type: "title",
  494. title: "订单备注",
  495. label: "",
  496. },
  497. {
  498. type: "slot",
  499. slotName: "remark",
  500. },
  501. ];
  502. });
  503. const rules = ref({
  504. province: [{ required: true, message: "请输入省", trigger: "blur" }],
  505. detailedAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  506. consignee: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  507. consigneeNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  508. deliveryTime: [{ required: true, message: "请选择交货时间", trigger: "change" }],
  509. // expressDeliveryId: [{ required: true, message: "请选择快递", trigger: "change" }],
  510. sourcePlatform: [{ required: true, message: "请选择店铺来源", trigger: "change" }],
  511. shopName: [{ required: true, message: "请选择店铺", trigger: "change" }],
  512. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  513. });
  514. const getDemandData = () => {
  515. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  516. if (res.rows && res.rows.length > 0) {
  517. departmentList.value = res.rows.map((item) => {
  518. return {
  519. dictKey: item.id,
  520. dictValue: item.name,
  521. };
  522. });
  523. }
  524. });
  525. };
  526. getDemandData();
  527. const drawingFileIndex = ref(0);
  528. const openDrawingFile = ref(false);
  529. const clickDrawingFile = (index) => {
  530. drawingFileIndex.value = index;
  531. openDrawingFile.value = true;
  532. };
  533. const selectPic = (row) => {
  534. formData.data.orderSkuList[drawingFileIndex.value].blueprint = row.imgUrl;
  535. formData.data.orderSkuList[drawingFileIndex.value].productionDocument = row.fileUrl;
  536. ElMessage({ message: "选择完成", type: "success" });
  537. openDrawingFile.value = false;
  538. };
  539. const openFile = (path) => {
  540. window.open(path);
  541. };
  542. const updatePackageRemark = (val, index) => {
  543. formData.data.orderSkuList[index].packageRemark = val;
  544. };
  545. const clickDelete = (index) => {
  546. formData.data.orderSkuList.splice(index, 1);
  547. };
  548. const updateValue = (val) => {
  549. formData.data.remark = val;
  550. };
  551. const submitForm = (status) => {
  552. submit.value.handleSubmit(() => {
  553. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  554. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  555. if (!formData.data.orderSkuList[i].blueprint) {
  556. return ElMessage("请选择设计图");
  557. }
  558. if (!formData.data.orderSkuList[i].productionDocument) {
  559. return ElMessage("请选择生产文件");
  560. }
  561. let packagingMaterialCost = 0;
  562. if (formData.data.orderSkuList[i].quantity) {
  563. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  564. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  565. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity && formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  566. packagingMaterialCost = Number(
  567. Math.round(
  568. (packagingMaterialCost +
  569. formData.data.orderSkuList[i].orderSkuBomList[j].quantity * formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) *
  570. 100
  571. ) / 100
  572. );
  573. }
  574. }
  575. }
  576. }
  577. formData.data.orderSkuList[i].packagingMaterialCost = packagingMaterialCost;
  578. }
  579. formData.data.productTotalAmount = calculatedAmount("unitPrice");
  580. formData.data.customProcessingFee = calculatedAmount("customProcessingFee");
  581. formData.data.lssueFee = calculatedAmount("lssueFee");
  582. formData.data.deliveryMaterialsFee = calculatedAmount("deliveryMaterialsFee");
  583. formData.data.packingLabor = calculatedAmount("packingLabor");
  584. formData.data.managementFee = calculatedAmount("managementFee");
  585. formData.data.packagingMaterialCost = calculatedPackagingMaterialCost();
  586. formData.data.totalAmount = calculatedTotalAmount();
  587. if (fileList.value && fileList.value.length > 0) {
  588. for (let i = 0; i < fileList.value.length; i++) {
  589. if (fileList.value[i].raw.uploadState) {
  590. return ElMessage("文件上传中,请稍后提交");
  591. }
  592. }
  593. formData.data.fileList = fileList.value.map((item) => {
  594. return {
  595. id: item.raw.id,
  596. fileName: item.raw.fileName,
  597. fileUrl: item.raw.fileUrl,
  598. };
  599. });
  600. } else {
  601. formData.data.fileList = [];
  602. }
  603. formData.data.status = status;
  604. let type = "add";
  605. if (formData.data.id) {
  606. type = "edit";
  607. }
  608. proxy.post("/orderInfo/" + type, formData.data).then(() => {
  609. ElMessage({
  610. message: type == "add" ? "添加成功" : "编辑成功",
  611. type: "success",
  612. });
  613. refreshStore().setRefresh("order");
  614. clickCancel();
  615. });
  616. } else {
  617. return ElMessage("请添加产品");
  618. }
  619. });
  620. };
  621. const clickCancel = () => {
  622. const useTagsStore = useTagsViewStore();
  623. useTagsStore.delVisitedView(router.currentRoute.value);
  624. if (route.query && route.query.orderInquiry) {
  625. router.replace({
  626. path: "/production/schedule/order-inquiry",
  627. });
  628. } else {
  629. router.replace({
  630. path: "/subsidiary/order/subsidiary-order-management",
  631. });
  632. }
  633. };
  634. onMounted(() => {
  635. if (route.query && (route.query.id || route.query.detailId)) {
  636. useTagsViewStore().visitedViews = useTagsViewStore().visitedViews.map((item) => {
  637. if (item.query && item.query.random === route.query.random) {
  638. return {
  639. ...item,
  640. name: route.query.text,
  641. title: route.query.text,
  642. };
  643. } else {
  644. return {
  645. ...item,
  646. };
  647. }
  648. });
  649. getOrderDetail({ id: route.query.id || route.query.detailId });
  650. }
  651. });
  652. const getOrderDetail = (parameter) => {
  653. proxy.post("/orderInfo/detail", parameter).then((res) => {
  654. formData.data = res;
  655. if (route.query.id) {
  656. proxy.$refs.editor.changeHtml(formData.data.remark);
  657. }
  658. if (route.query.detailId) {
  659. let allIndex = [];
  660. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  661. allIndex.push(i);
  662. }
  663. activeNames.value = allIndex;
  664. formOption.disabled = true;
  665. }
  666. proxy.post("/fileInfo/getList", { businessIdList: [formData.data.id] }).then((fileObj) => {
  667. if (fileObj[formData.data.id] && fileObj[formData.data.id].length > 0) {
  668. let list = fileObj[formData.data.id].filter((item) => item.businessType == "0");
  669. if (list && list.length > 0) {
  670. fileList.value = list.map((item) => {
  671. return {
  672. raw: item,
  673. name: item.fileName,
  674. url: item.fileUrl,
  675. };
  676. });
  677. } else {
  678. fileList.value = [];
  679. }
  680. }
  681. });
  682. });
  683. };
  684. const getStyle = (text) => {
  685. if (text) {
  686. return text.replace(/\n|\r\n/g, "<br>");
  687. } else {
  688. return "";
  689. }
  690. };
  691. const openProduct = ref(false);
  692. const clickAddProduct = () => {
  693. openProduct.value = true;
  694. };
  695. const printType = ref([
  696. {
  697. dictKey: 1,
  698. dictValue: "单面",
  699. },
  700. {
  701. dictKey: 2,
  702. dictValue: "双面",
  703. },
  704. ]);
  705. const selectProduct = (row, SKU) => {
  706. if (row.id) {
  707. let list = formData.data.orderSkuList.filter((item) => item.skuSpecId === row.id && item.bomSpecId === row.bomSpecId);
  708. if (list && list.length > 0) {
  709. return ElMessage("该产品已添加");
  710. }
  711. proxy.post("/sku/detail", { id: SKU.id }).then((res) => {
  712. let orderSkuBomList = [];
  713. if (res.skuSpecList && res.skuSpecList.length > 0) {
  714. let listTwo = res.skuSpecList.filter((item) => item.id === row.id);
  715. if (listTwo && listTwo.length > 0) {
  716. if (listTwo[0].packagingMaterialList && listTwo[0].packagingMaterialList.length > 0) {
  717. orderSkuBomList = listTwo[0].packagingMaterialList.map((item) => {
  718. return {
  719. bomSpecId: item.bomSpecId,
  720. unitPrice: item.internalSellingPrice,
  721. quantity: item.quantity,
  722. bomSpecName: item.name,
  723. };
  724. });
  725. }
  726. }
  727. }
  728. formData.data.orderSkuList.push({
  729. wlnSkuName: SKU.name,
  730. skuId: row.skuId,
  731. code: row.code,
  732. name: row.name,
  733. skuSpecId: row.id,
  734. bomSpecId: row.bomSpecId,
  735. quantity: undefined,
  736. customProcessingFee: "",
  737. customProcessingType: "",
  738. lssueFee: "",
  739. deliveryMaterialsFee: "",
  740. packingLabor: "",
  741. managementFee: "",
  742. unitPrice: "",
  743. printType: 1,
  744. packageRemark: "",
  745. orderSkuBomList: orderSkuBomList,
  746. blueprint: row.designImgUrl,
  747. productionDocument: row.sharedFolder,
  748. });
  749. ElMessage({ message: "添加成功", type: "success" });
  750. });
  751. } else {
  752. ElMessage("添加失败");
  753. }
  754. };
  755. const rowIndex = ref(null);
  756. const openPackingFittings = ref(false);
  757. const clickPackingFittings = (index) => {
  758. rowIndex.value = index;
  759. openPackingFittings.value = true;
  760. };
  761. const clickDeletePackingFittings = (index, indexTwo) => {
  762. formData.data.orderSkuList[index].orderSkuBomList.splice(indexTwo, 1);
  763. };
  764. const selectPackingFittings = (data) => {
  765. if (formData.data.orderSkuList[rowIndex.value].orderSkuBomList && formData.data.orderSkuList[rowIndex.value].orderSkuBomList.length > 0) {
  766. let list = formData.data.orderSkuList[rowIndex.value].orderSkuBomList.filter((item) => item.bomSpecId === data.id);
  767. if (list && list.length > 0) {
  768. return ElMessage("包材配件已添加");
  769. }
  770. formData.data.orderSkuList[rowIndex.value].orderSkuBomList.push({
  771. bomSpecId: data.id,
  772. unitPrice: data.internalSellingPrice,
  773. quantity: undefined,
  774. bomSpecName: data.name,
  775. });
  776. } else {
  777. formData.data.orderSkuList[rowIndex.value].orderSkuBomList = [
  778. {
  779. bomSpecId: data.id,
  780. unitPrice: data.internalSellingPrice,
  781. quantity: undefined,
  782. bomSpecName: data.name,
  783. },
  784. ];
  785. }
  786. ElMessage({ message: "添加成功", type: "success" });
  787. };
  788. const changeQuantity = (index) => {
  789. if (formData.data.orderSkuList[index].quantity) {
  790. proxy
  791. .post("/orderInfo/getSkuSpecPrice", { skuSpecId: formData.data.orderSkuList[index].skuSpecId, quantity: formData.data.orderSkuList[index].quantity })
  792. .then((res) => {
  793. if (formData.data.orderSkuList[index].printType == 2 && res.customProcessingFee) {
  794. formData.data.orderSkuList[index].customProcessingFee = Number(Math.round(res.customProcessingFee * 2 * 100) / 100);
  795. } else {
  796. formData.data.orderSkuList[index].customProcessingFee = res.customProcessingFee;
  797. }
  798. formData.data.orderSkuList[index].customProcessingType = res.customProcessingType;
  799. formData.data.orderSkuList[index].deliveryMaterialsFee = res.deliveryMaterialsFee;
  800. formData.data.orderSkuList[index].lssueFee = res.lssueFee;
  801. formData.data.orderSkuList[index].packingLabor = res.packingLabor;
  802. formData.data.orderSkuList[index].managementFee = res.managementFee;
  803. formData.data.orderSkuList[index].unitPrice = res.unitPrice;
  804. });
  805. }
  806. };
  807. const cellStyleName = ({ column, columnIndex }) => {
  808. if (column.label === "操作" && columnIndex === 3) {
  809. return "vertical-align";
  810. }
  811. };
  812. const uploadData = ref({});
  813. const uploadFile = async (file) => {
  814. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  815. uploadData.value = res.uploadBody;
  816. file.id = res.id;
  817. file.fileName = res.fileName;
  818. file.fileUrl = res.fileUrl;
  819. return true;
  820. };
  821. const handleSuccess = (UploadFile, index) => {
  822. formData.data.orderSkuList[index].productionDocument = UploadFile.raw.fileUrl;
  823. };
  824. const uploadImgData = ref({});
  825. const uploadImgFile = async (file) => {
  826. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  827. uploadImgData.value = res.uploadBody;
  828. file.id = res.id;
  829. file.fileName = res.fileName;
  830. file.fileUrl = res.fileUrl;
  831. return true;
  832. };
  833. const handleImgSuccess = (UploadFile, index) => {
  834. formData.data.orderSkuList[index].blueprint = UploadFile.raw.fileUrl;
  835. };
  836. const computeQuantity = (index, indexSKU) => {
  837. let quantity = 0;
  838. if (formData.data.orderSkuList[index].quantity && formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity) {
  839. quantity = Number(
  840. Math.round(formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity * formData.data.orderSkuList[index].quantity * 100) / 100
  841. );
  842. }
  843. return quantity;
  844. };
  845. const computeMoney = (index, indexSKU) => {
  846. let money = 0;
  847. if (
  848. formData.data.orderSkuList[index].quantity &&
  849. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity &&
  850. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].unitPrice
  851. ) {
  852. money = Number(
  853. Math.round(
  854. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].quantity *
  855. formData.data.orderSkuList[index].orderSkuBomList[indexSKU].unitPrice *
  856. formData.data.orderSkuList[index].quantity *
  857. 100
  858. ) / 100
  859. );
  860. }
  861. return money;
  862. };
  863. const getSubtotal = (item) => {
  864. let money = 0;
  865. if (item.quantity) {
  866. money = Number(
  867. Math.round(
  868. (item.customProcessingFee + item.deliveryMaterialsFee + item.lssueFee + item.packingLabor + item.managementFee + item.unitPrice) * item.quantity * 100
  869. ) / 100
  870. );
  871. }
  872. return money;
  873. };
  874. const calculatedAmount = (label) => {
  875. let money = 0;
  876. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  877. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  878. if (formData.data.orderSkuList[i].quantity && formData.data.orderSkuList[i][label]) {
  879. money = Number(Math.round((money + formData.data.orderSkuList[i][label] * formData.data.orderSkuList[i].quantity) * 100) / 100);
  880. }
  881. }
  882. }
  883. return money;
  884. };
  885. const calculatedPackagingMaterialCost = () => {
  886. let money = 0;
  887. if (formData.data.orderSkuList && formData.data.orderSkuList.length > 0) {
  888. for (let i = 0; i < formData.data.orderSkuList.length; i++) {
  889. if (formData.data.orderSkuList[i].orderSkuBomList && formData.data.orderSkuList[i].orderSkuBomList.length > 0) {
  890. for (let j = 0; j < formData.data.orderSkuList[i].orderSkuBomList.length; j++) {
  891. if (formData.data.orderSkuList[i].orderSkuBomList[j].quantity && formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice) {
  892. money = Number(
  893. Math.round(
  894. (money +
  895. formData.data.orderSkuList[i].orderSkuBomList[j].quantity *
  896. formData.data.orderSkuList[i].orderSkuBomList[j].unitPrice *
  897. formData.data.orderSkuList[i].quantity) *
  898. 100
  899. ) / 100
  900. );
  901. }
  902. }
  903. }
  904. }
  905. }
  906. return money;
  907. };
  908. const calculatedTotalAmount = () => {
  909. let money = 0;
  910. money = Number(
  911. Math.round(
  912. (calculatedAmount("unitPrice") +
  913. calculatedAmount("customProcessingFee") +
  914. calculatedAmount("lssueFee") +
  915. calculatedAmount("deliveryMaterialsFee") +
  916. calculatedAmount("packingLabor") +
  917. calculatedAmount("managementFee") +
  918. calculatedPackagingMaterialCost()) *
  919. 100
  920. ) / 100
  921. );
  922. return money;
  923. };
  924. const fileList = ref([]);
  925. const uploadFileData = ref({});
  926. const beforeUpload = async (file) => {
  927. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  928. uploadFileData.value = res.uploadBody;
  929. file.id = res.id;
  930. file.fileName = res.fileName;
  931. file.fileUrl = res.fileUrl;
  932. file.uploadState = true;
  933. return true;
  934. };
  935. const onSuccessFile = (any, UploadFile) => {
  936. UploadFile.raw.uploadState = false;
  937. };
  938. const onPreviewFile = (file) => {
  939. window.open(file.raw.fileUrl, "_blank");
  940. };
  941. </script>
  942. <style lang="scss" scoped>
  943. ::v-deep(.el-input-number .el-input__inner) {
  944. text-align: left;
  945. }
  946. :deep(.el-dialog) {
  947. margin-top: 10px !important;
  948. margin-bottom: 10px !important;
  949. }
  950. :deep(.ql-editor) {
  951. height: auto;
  952. }
  953. :deep(.el-collapse-item__header) {
  954. justify-content: center;
  955. }
  956. :deep(.el-collapse-item__arrow) {
  957. margin: 0;
  958. }
  959. :deep(.el-table__cell) {
  960. vertical-align: top;
  961. }
  962. :deep(.vertical-align) {
  963. vertical-align: middle;
  964. }
  965. </style>