collectCloth.vue 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731
  1. <template>
  2. <div class="app-container" style="height: calc(100vh - 84px)">
  3. <el-main style="height: calc(100vh - 180px - 84px)">
  4. <el-row :gutter="20">
  5. <el-col :span="6" :xs="24">
  6. <el-card class="box-card">
  7. <div slot="header" class="clearfix">
  8. <span>选择客户</span>
  9. </div>
  10. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" @submit.native.prevent>
  11. <el-form-item prop="phoneNumber">
  12. <el-input v-model="queryParams.phoneNumber" placeholder="请输入手机号" clearable @keyup.enter.native="searchUser" />
  13. </el-form-item>
  14. <!-- <el-form-item label="姓名" prop="realName">-->
  15. <!-- <el-input-->
  16. <!-- v-model="queryParams.realName"-->
  17. <!-- placeholder="请输入姓名"-->
  18. <!-- clearable-->
  19. <!-- @keyup.enter.native="handleQuery"-->
  20. <!-- />-->
  21. <!-- </el-form-item>-->
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-full-screen" @click="qrcodeSearchUser">扫码</el-button>
  24. <el-button type="primary" icon="el-icon-search" @click="searchUser">查询</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-descriptions title="用户信息" v-if="appUserInfo" :column="2">
  28. <el-descriptions-item label="用户名">{{ appUserInfo.realName }}</el-descriptions-item>
  29. <el-descriptions-item label="手机号">{{ appUserInfo.phoneNumber }}</el-descriptions-item>
  30. <el-descriptions-item label="等级">{{ appUserInfo.level }}</el-descriptions-item>
  31. <el-descriptions-item label="现金余额">
  32. {{ (appUserInfo.rechargeBalance * 100) / 100 }}
  33. </el-descriptions-item>
  34. <el-descriptions-item label="赠送余额">
  35. {{ (appUserInfo.giveBalance * 100) / 100 }}
  36. </el-descriptions-item>
  37. <el-descriptions-item label="福利金">
  38. {{ (appUserInfo.welfareBalance * 100) / 100 }}
  39. </el-descriptions-item>
  40. <el-descriptions-item label="地址" :span="2">{{ appUserInfo.defaultAddress ? appUserInfo.defaultAddress.address + ' ' + appUserInfo.defaultAddress.addressDetail : '' }}</el-descriptions-item>
  41. </el-descriptions>
  42. <!-- -->
  43. <el-button type="text" @click="showAdvanceOrder = true">选择预约订单</el-button>
  44. </el-card>
  45. </el-col>
  46. <el-col :span="18" :xs="24">
  47. <div style="width: 100%" class="verticle-view">
  48. <el-form :inline="true" label-width="68px">
  49. <el-form-item>
  50. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd">添加衣物</el-button>
  51. </el-form-item>
  52. </el-form>
  53. <el-table :data="orderClothItemDTOS" fit highlight-current-row border stripe ref="clothTable">
  54. <el-table-column label="序号" type="index" align="center" fixed="left" width="80"> </el-table-column>
  55. <el-table-column label="衣物名称" align="center" prop="name">
  56. <template slot-scope="scope">
  57. <el-button type="text" @click="updateClothItem(scope.$index, 0)">{{ calculateClothName(scope.$index) }}</el-button>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="颜色" align="center" width="120">
  61. <template slot-scope="scope">
  62. <el-button type="text" @click="updateClothItem(scope.$index, 2)">
  63. <template v-for="(color, index) in scope.row.orderClothColorDTOS">
  64. {{ index == 0 ? color.clothColorName : ',' + color.clothColorName }}
  65. </template>
  66. </el-button>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="衣服品牌" align="center" prop="name" width="120">
  70. <template slot-scope="scope">
  71. <el-button type="text" @click="updateClothItem(scope.$index, 3)">{{ scope.row.clothBrandName }}</el-button>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="瑕疵" align="center">
  75. <template slot-scope="scope">
  76. <el-button type="text" @click="updateClothItem(scope.$index, 4)">
  77. <template v-for="(color, index) in scope.row.orderClothFlawDTOS">
  78. {{ index == 0 ? color.clothFlawName : ',' + color.clothFlawName }}
  79. </template>
  80. </el-button>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="洗涤方式" align="center" width="80">
  84. <template slot-scope="scope">
  85. <el-button type="text" @click="changeClothWashMode(scope.$index)" style="color: #409eff">{{ scope.row.clothWashModeName }}</el-button>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="特殊处理(元)" align="center" prop="clothWashDayNum" width="120">
  89. <template slot-scope="scope">
  90. <el-button type="text" style="color: #ff4949" @click="changeClothSpecialPriceEvent(scope.$index)">¥{{ calculateClothSpecialPrice(scope.$index) }}</el-button>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="单价(元)" align="center" prop="defaultPrice" width="100">
  94. <template slot-scope="scope">
  95. <!-- style="color: #ff4949" -->
  96. <el-button type="text" v-if="scope.row.isChangePrice == 'Y'" @click="changeClothDefaultPriceEvent(scope.$index)">¥{{ scope.row.defaultPrice }}</el-button>
  97. <span v-else>¥{{ scope.row.defaultPrice }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
  101. <template slot-scope="scope">
  102. <el-button type="text" @click="handleAddClothFlaw(scope.$index)">附件({{ scope.row.orderClothAdjunctDTOS.length }})</el-button>
  103. <!-- <el-button
  104. type="text"
  105. @click="handleAddClothPics(scope.$index)"
  106. >
  107. {{'拍照(' + scope.row.picNum + ')'}}
  108. </el-button> -->
  109. <el-button type="text" icon="el-icon-camera" @click="handphotograph(scope.$index)">{{ '拍照(' + scope.row.picNum + ')' }}</el-button>
  110. <el-button type="text" style="color: #ff4949" @click="orderClothItemDTOS.splice(scope.$index, 1)">删除</el-button>
  111. <el-button type="text" @click="handleRemarkClothItem(scope.$index)">备注</el-button>
  112. <el-button type="text" @click="handleCopyClothItem(scope.$index)">复制</el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. </div>
  117. </el-col>
  118. </el-row>
  119. </el-main>
  120. <el-row :gutter="10" class="box-shadow">
  121. <el-col :span="21">
  122. <el-form label-width="100px" style="height: 180px; padding-top: 20px" :inline="true" size="medium" :model="orderForm" ref="orderForm">
  123. <el-form-item label="总件数:" prop="totalClothNum">
  124. <span>{{ orderClothItemDTOS.length }}</span>
  125. </el-form-item>
  126. <el-form-item label="总金额:" prop="totalPrice">
  127. <span>{{ calculateTotalPrice() }}</span>
  128. </el-form-item>
  129. <el-form-item label="实收金额:" prop="totalPrice">
  130. <span style="color: #ff4949">{{ calculateTotalPrice() }}</span>
  131. </el-form-item>
  132. <el-form-item label="订单加急" prop="orderSpeed">
  133. <el-select v-model="orderForm.speed" placeholder="请选择" clearable>
  134. <template v-for="(item, index) in clothSpeeds">
  135. <el-option v-if="index > 1" :key="item.id" :label="item.name" :value="item.id"> </el-option>
  136. </template>
  137. </el-select>
  138. </el-form-item>
  139. <el-form-item label="是否关联预约" prop="isAppointment">
  140. <el-radio-group v-model="orderForm.isAppointment">
  141. <el-radio-button v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio-button>
  142. </el-radio-group>
  143. </el-form-item>
  144. <el-form-item label="预约单号" prop="orderNo" v-if="orderForm.isAppointment == 'Y'">
  145. <el-input v-model="orderForm.orderNo" placeholder="请输入预约单号" clearable required />
  146. </el-form-item>
  147. <br />
  148. <el-form-item label="会员余额:" prop="userAmount">
  149. <span v-if="appUserInfo">{{ Math.round((appUserInfo.rechargeBalance + appUserInfo.giveBalance) * 100) / 100 }}</span>
  150. <span v-else>0</span>
  151. </el-form-item>
  152. <!-- <el-form-item label="取衣时间" prop="takeClothTime">
  153. <el-date-picker
  154. v-model="orderForm.takeClothTime"
  155. format="yyyy-MM-dd HH:mm"
  156. value-format="yyyy-MM-dd HH:mm"
  157. :style="{width: '100%'}"
  158. placeholder="请选择取衣时间"
  159. clearable
  160. ></el-date-picker>
  161. </el-form-item> -->
  162. <el-form-item v-if="orderForm.isAppointment == 'Y'" label="取衣方式" prop="sendClothWay">
  163. <el-select v-model="orderForm.sendClothWay" placeholder="请选择" clearable>
  164. <el-option v-for="dict in dict.type.cloth_send_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  165. </el-select>
  166. </el-form-item>
  167. <el-form-item label="备注" prop="remark">
  168. <el-input v-model="orderForm.remark" placeholder="请输入订单备注" clearable />
  169. </el-form-item>
  170. </el-form>
  171. </el-col>
  172. <el-col :span="3">
  173. <el-button type="danger" style="height: 100%; width: 80%; height: 120px; margin-top: 30px" icon="el-icon-shopping-cart-2" size="medium" @click="handleConfirmPay">收银</el-button>
  174. </el-col>
  175. <!-- <el-col :span="3">-->
  176. <!-- <el-button type="primary" style="height: 100%; width: 80%; height: 120px; margin-top: 30px" icon="el-icon-sell">取衣付款</el-button>-->
  177. <!-- </el-col>-->
  178. </el-row>
  179. <!-- 添加或修改洗衣订单衣服明细对话框 -->
  180. <el-dialog :title="title" :visible.sync="open" size="50%" append-to-body>
  181. <el-row :gutter="15">
  182. <el-col :span="24">
  183. <el-steps :active="addClothActiveTab" finish-status="success" simple>
  184. <el-step title="衣服分类"></el-step>
  185. <el-step title="选择衣服"></el-step>
  186. <el-step title="衣服颜色"></el-step>
  187. <el-step title="衣服品牌"></el-step>
  188. <el-step title="衣服瑕疵"></el-step>
  189. <el-step title="衣服附件"></el-step>
  190. </el-steps>
  191. </el-col>
  192. <el-col>
  193. <div style="height: 20px"></div>
  194. </el-col>
  195. <el-col :span="24" v-if="addClothActiveTab == 0">
  196. <div style="margin-left: 55px">
  197. <el-input v-model="defaultList.type" placeholder="请输入要搜索的衣服分类" style="width: 300px" clearable>
  198. <el-button slot="append" icon="el-icon-search" @click="searchCloth('type', 'clothTypes')"></el-button>
  199. </el-input>
  200. </div>
  201. <div style="margin-left: 40px">
  202. <el-tag :key="item.id" type="info" v-for="item in clothTypes" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothTypeSelect(item.id)">
  203. {{ item.name }}
  204. </el-tag>
  205. </div>
  206. </el-col>
  207. <el-col :span="24" v-if="addClothActiveTab == 1">
  208. <div style="margin-left: 55px; margin-bottom: 10px">
  209. <el-input v-model="defaultList.item" placeholder="请输入要搜索的衣服类型" style="width: 300px" clearable>
  210. <el-button slot="append" icon="el-icon-search" @click="searchCloth('item', 'clothItems')"></el-button>
  211. </el-input>
  212. </div>
  213. <div style="margin-left: 40px">
  214. <div class="horizontal-view" style="margin-left: 15px">
  215. <span style="font-size: 14px; line-height: 19px">衣服类型:</span>
  216. <el-checkbox-group style="margin-left: 20px" v-model="form.clothTypeKeys">
  217. <el-checkbox v-for="dict in dict.type.cloth_type" :key="dict.value" :label="dict.value">{{ dict.label }}</el-checkbox>
  218. </el-checkbox-group>
  219. </div>
  220. <el-tag :key="item.id" type="info" v-for="(item, index) in clothItems" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothItemSelect(index)">
  221. {{ item.name }}
  222. </el-tag>
  223. </div>
  224. </el-col>
  225. <el-col :span="24" v-if="addClothActiveTab == 2">
  226. <div style="margin-left: 55px; margin-bottom: 10px">
  227. <el-input v-model="defaultList.color" placeholder="请输入要搜索的衣服颜色" style="width: 300px" clearable>
  228. <el-button slot="append" icon="el-icon-search" @click="searchCloth('color', 'clothColors')"></el-button>
  229. </el-input>
  230. </div>
  231. <div style="margin-left: 40px; display: flex; flex-wrap: wrap">
  232. <template v-for="(item, index) in clothColors">
  233. <div class="verticle-view" :style="'text-align: center;margin-top: 15px;margin-left: 15px;border-radius: 5px;border: 1px solid ' + (item.isSelect == true ? '#1890ff' : '#FFFFFF')" @click="onClothColorSelect(index)">
  234. <template v-if="item.colorType == 0">
  235. <div :style="'width: 50px;height: 50px;border:1px solid #ededed;border-radius: 5px;background-color:' + item.code"></div>
  236. </template>
  237. <template v-if="item.colorType == 1">
  238. <img :src="item.imgUrl" style="width: 50px; height: 50px; border-radius: 5px" />
  239. </template>
  240. <span style="height: 40px; line-height: 40px">{{ item.name }}</span>
  241. </div>
  242. </template>
  243. </div>
  244. </el-col>
  245. <el-col :span="24" v-if="addClothActiveTab == 3">
  246. <div style="margin-left: 55px">
  247. <el-input v-model="defaultList.brand" placeholder="请输入要搜索的衣服品牌" style="width: 300px" clearable>
  248. <el-button slot="append" icon="el-icon-search" @click="searchCloth('brand', 'clothBrands')"></el-button>
  249. </el-input>
  250. </div>
  251. <div style="margin-left: 40px">
  252. <el-tag :key="item.id" type="info" v-for="item in clothBrands" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothBrandSelect(item.id)">
  253. {{ item.name }}
  254. </el-tag>
  255. </div>
  256. </el-col>
  257. <el-col :span="24" v-if="addClothActiveTab == 4">
  258. <el-tabs type="border-card" @tab-click="changeClothTab">
  259. <el-tab-pane label="全部">
  260. <div style="margin-left: 15px">
  261. <el-input v-model="defaultList.flaw" placeholder="请输入要搜索的衣服瑕疵" style="width: 300px" clearable>
  262. <el-button slot="append" icon="el-icon-search" @click="searchCloth('flaw', 'clothFlaws')"></el-button>
  263. </el-input>
  264. </div>
  265. <el-tag :key="item.id" :type="item.isSelect ? 'success' : 'info'" v-for="(item, index) in clothFlaws" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothFlawSelect(index)">
  266. {{ item.name }}
  267. </el-tag>
  268. </el-tab-pane>
  269. <el-tab-pane :label="clothFlawType.name" v-for="clothFlawType in clothFlawTypes">
  270. <div style="margin-left: 15px">
  271. <el-input v-model="defaultList.flaw" placeholder="请输入要搜索的衣服瑕疵" style="width: 300px" clearable>
  272. <el-button slot="append" icon="el-icon-search" @click="searchCloth('flaw', 'clothFlaws')"></el-button>
  273. </el-input>
  274. </div>
  275. <template v-for="(item, index) in clothFlaws">
  276. <el-tag :key="item.id" :type="item.isSelect ? 'success' : 'info'" v-if="item.flawTypeId == clothFlawType.id" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothFlawSelect(index)">
  277. {{ item.name }}
  278. </el-tag>
  279. </template>
  280. </el-tab-pane>
  281. </el-tabs>
  282. </el-col>
  283. <el-col :span="24" v-if="addClothActiveTab == 5">
  284. <el-row :gutter="20">
  285. <el-col :span="8">
  286. <div>选择附件</div>
  287. <div style="margin-left: 15px; margin-top: 10px">
  288. <el-input v-model="defaultList.adjunct" placeholder="请输入要搜索的衣服附件" style="width: 300px" clearable>
  289. <el-button slot="append" icon="el-icon-search" @click="searchCloth('adjunct', 'clothAdjuncts')"></el-button>
  290. </el-input>
  291. </div>
  292. <el-tag :key="item.id" type="info" v-for="item in clothAdjuncts" style="margin-top: 15px; margin-left: 15px" @click="onClothAdjunctSelect(item)">
  293. {{ item.name }}
  294. </el-tag>
  295. </el-col>
  296. <el-col :span="16">
  297. <el-table :data="addClothAdjuncts" style="width: 100%">
  298. <el-table-column label="附件" align="center" prop="adjunctName" />
  299. <el-table-column label="数量" align="center" prop="num">
  300. <template slot-scope="scope">
  301. <el-input-number v-model="scope.row.num" size="small" :precision="0" :min="1" :max="999"></el-input-number>
  302. </template>
  303. </el-table-column>
  304. <el-table-column label="操作" align="center">
  305. <template slot-scope="scope">
  306. <el-button type="text" icon="el-icon-delete" @click="removeClothAdjunct(scope.$index)">删除</el-button>
  307. </template>
  308. </el-table-column>
  309. </el-table>
  310. </el-col>
  311. </el-row>
  312. </el-col>
  313. </el-row>
  314. <div slot="footer" class="dialog-footer" v-if="addClothActiveTab == 2 || addClothActiveTab == 4 || addClothActiveTab == 5">
  315. <el-button type="primary" @click="addClothItemConfirm" style="margin-left: 5%">确定</el-button>
  316. </div>
  317. </el-dialog>
  318. <el-dialog title="衣服附件" :visible.sync="addClothAdjunctOpen" width="60%">
  319. <el-row :gutter="20">
  320. <el-col :span="8">
  321. <div>选择附件</div>
  322. <div style="margin-left: 15px; margin-top: 10px">
  323. <el-input v-model="defaultList.adjunct" placeholder="请输入要搜索的衣服附件" style="width: 300px" clearable>
  324. <el-button slot="append" icon="el-icon-search" @click="searchCloth('adjunct', 'clothAdjuncts')"></el-button>
  325. </el-input>
  326. </div>
  327. <el-tag :key="item.id" type="info" v-for="item in clothAdjuncts" style="margin-top: 15px; margin-left: 15px" @click="onClothAdjunctSelect(item)">
  328. {{ item.name }}
  329. </el-tag>
  330. </el-col>
  331. <el-col :span="16">
  332. <el-table :data="addClothAdjuncts" style="width: 100%">
  333. <el-table-column label="附件" align="center" prop="adjunctName" />
  334. <el-table-column label="数量" align="center" prop="num">
  335. <template slot-scope="scope">
  336. <el-input-number v-model="scope.row.num" size="small" :precision="0" :min="1" :max="999"></el-input-number>
  337. </template>
  338. </el-table-column>
  339. <el-table-column label="操作" align="center">
  340. <template slot-scope="scope">
  341. <el-button type="text" icon="el-icon-delete" @click="removeClothAdjunct(scope.$index)">删除</el-button>
  342. </template>
  343. </el-table-column>
  344. </el-table>
  345. </el-col>
  346. </el-row>
  347. <span slot="footer" class="dialog-footer">
  348. <el-button @click="addClothAdjunctOpen = false">取 消</el-button>
  349. <el-button type="primary" @click="addClothAdjunctSubmit">确 定</el-button>
  350. </span>
  351. </el-dialog>
  352. <el-dialog title="衣服照片" :visible.sync="addClothPicOpen" width="50%">
  353. <form ref="picForm">
  354. <image-upload :limit="9" v-model="addClothPics"></image-upload>
  355. </form>
  356. <span slot="footer" class="dialog-footer">
  357. <el-button @click="addClothPicOpen = false">取 消</el-button>
  358. <el-button type="primary" @click="addClothPicSubmit">确 定</el-button>
  359. </span>
  360. </el-dialog>
  361. <el-dialog title="洗衣方式" :visible.sync="addClothWashModeOpen" width="30%">
  362. <div style="margin-bottom: 50px">
  363. <el-tag :key="item.id" type="info" v-for="(item, index) in clothWashModes" style="margin-top: 15px; margin-left: 15px" size="medium" @click="onClothWashModeSelect(index)">
  364. {{ item.washModeName + '(¥' + item.price + ')' }}
  365. </el-tag>
  366. </div>
  367. </el-dialog>
  368. <!-- 设置备注 -->
  369. <el-dialog title="备注" :visible.sync="addClothRemarkOpen" width="30%">
  370. <form ref="remarkForm">
  371. <el-input type="textarea" :rows="5" placeholder="请输入备注" v-model="clothRemark"> </el-input>
  372. </form>
  373. <span slot="footer" class="dialog-footer">
  374. <el-button @click="addClothPicOpen = false">取 消</el-button>
  375. <el-button type="primary" @click="addClothRemarkSubmit">确 定</el-button>
  376. </span>
  377. </el-dialog>
  378. <!-- 设置默认价格 -->
  379. <el-dialog title="设置价格" :visible.sync="setClothDefaultPriceOpen" width="30%" :before-close="handleClose">
  380. <form ref="remarkForm">
  381. <el-input-number placeholder="请输入价格" v-model="defaultPrice"> </el-input-number>
  382. </form>
  383. <span slot="footer" class="dialog-footer">
  384. <el-button @click="setClothDefaultPriceOpen = false">取 消</el-button>
  385. <el-button type="primary" @click="setClothDefaultPriceSubmit">确 定</el-button>
  386. </span>
  387. </el-dialog>
  388. <!-- 特殊衣物 -->
  389. <el-dialog title="特殊衣物" :visible.sync="setClothSpecialPriceOpen" width="55%" :before-close="handleClose">
  390. <el-form ref="remarkForm">
  391. <el-row :gutter="10">
  392. <el-col :span="12">
  393. <el-card class="box-card">
  394. <div slot="header" class="clearfix">
  395. <span>工艺加价</span>
  396. </div>
  397. <template v-for="(item, index) in clothSpecialForm.clothCrafts">
  398. <el-form-item>
  399. <el-checkbox v-model="item.isSelect" @change="changeClothCraftSelect()" style="width: 100px">{{ item.clothCraftName }}</el-checkbox>
  400. <el-input-number v-model="item.price" :min="0" :max="9999" :precision="2" @change="changeClothCraftSelect"></el-input-number>
  401. </el-form-item>
  402. </template>
  403. </el-card>
  404. </el-col>
  405. <el-col :span="12">
  406. <el-card class="box-card">
  407. <div slot="header" class="clearfix">
  408. <span>保值加急</span>
  409. </div>
  410. <el-form-item>
  411. <el-checkbox v-model="clothSpecialForm.isHedging" @change="changeClothHedgingSelect()" style="width: 100px">保值</el-checkbox>
  412. <el-input-number v-model="clothSpecialForm.hedgingPrice" :min="0" :max="9999" :precision="0" @change="changeClothHedgingSelect()"></el-input-number>
  413. <span style="margin-left: 5px">元 {{ clothSpecialForm.hedgingPrice && clothSpecialForm.isHedging ? '(¥' + clothSpecialForm.hedgingPrice * 0.01 + ')' : '' }}</span>
  414. </el-form-item>
  415. <template v-for="(item, index) in clothSpecialForm.clothSpeeds">
  416. <el-form-item v-if="item.isDefault != 'Y' && selectClothItemIndex > -1">
  417. <el-checkbox v-model="item.isSelect" @change="changeClothSpeedSelect(index)" style="width: 100px" :disabled="clothSpecialForm.isHedging && index == 1">
  418. <span v-if="item.isSelect && orderClothItemDTOS[selectClothItemIndex]">{{ item.name + '(¥' + orderClothItemDTOS[selectClothItemIndex].defaultPrice * (item.multiple - 1) + ')' }}</span>
  419. <span v-else>{{ item.name }}</span>
  420. </el-checkbox>
  421. <span>{{ item.price }}</span>
  422. </el-form-item>
  423. </template>
  424. </el-card>
  425. </el-col>
  426. </el-row>
  427. </el-form>
  428. <span slot="footer" class="dialog-footer">
  429. <el-button @click="setClothSpecialPriceOpen = false">取 消</el-button>
  430. <el-button type="primary" @click="addClothSpecialSubmit">确 定</el-button>
  431. </span>
  432. </el-dialog>
  433. <el-dialog title="收银" :visible.sync="confirmPayOpen" size="80%" :before-close="handleClose" destroy-on-close>
  434. <CashCloth ref="cashCloth" :orderForm="orderForm" :orderClothItemDTOS="orderClothItemDTOS" :appUserInfo="appUserInfo" :clothSpeeds="clothSpeeds" :deductCouponVOS="deductCouponVOS" :discountCouponVOS="discountCouponVOS" @onPaySuccess="onPaySuccess" @initOrderList="initOrderList" />
  435. </el-dialog>
  436. <!-- 拍照上传 -->
  437. <el-dialog title="拍照上传" :visible.sync="photographType" :before-close="hidephotograph" width="55%">
  438. <div class="photo_content">
  439. <div class="video_content">
  440. <div class="loading" v-if="videoType">
  441. <el-button type="text" :loading="true" disabled>加载中请稍后</el-button>
  442. </div>
  443. <video class="videoElement" ref="videoElement" autoplay></video>
  444. </div>
  445. <div class="view">
  446. <div class="btn_box">
  447. <el-button class="btn_photo" :loading="photoType" :disabled="photoType" icon="el-icon-camera" type="primary" plain @click="takePhoto" v-if="!videoType">拍照上传</el-button>
  448. <el-upload v-if="photographimgList.length < 9" class="btn_upload" :action="uploadAction" :before-upload="handleBeforeUpload" :on-success="handleUploadSuccess" :on-error="handleUploadError" accept="image/*" :show-file-list="false" ref="fileUpload">
  449. <el-button icon="el-icon-folder" plain type="primary">上传本地文件</el-button>
  450. </el-upload>
  451. </div>
  452. <div class="image_list" v-if="photographimgList.length">
  453. <div class="image_item" v-for="(item, index) in photographimgList" :key="index">
  454. <el-image style="width: 120px; height: 120px" :src="item.src ? item.src : item.url" :preview-src-list="previewimgList"> </el-image>
  455. <div class="image_bottom">
  456. <el-button type="danger" icon="el-icon-delete" @click="btn_remove(item, index)"></el-button>
  457. <el-button v-if="item.type" type="success" icon="el-icon-check"></el-button>
  458. </div>
  459. </div>
  460. </div>
  461. <el-empty :image-size="200" v-else></el-empty>
  462. </div>
  463. </div>
  464. <span slot="footer" class="dialog-footer">
  465. <el-button @click="hidephotograph">关 闭</el-button>
  466. <el-button type="primary" @click="btn_submit">保 存</el-button>
  467. </span>
  468. </el-dialog>
  469. <pay-status-popup ref="payStatusPopup" @paySuccess="handelPaySuccess"></pay-status-popup>
  470. <el-dialog title="预约订单" :visible.sync="showAdvanceOrder" width="55%">
  471. <el-table :data="advanceOrderList">
  472. <el-table-column prop="date" label="预约单号" width="180"> </el-table-column>
  473. <el-table-column prop="date" label="预约时间" width="180"> </el-table-column>
  474. <el-table-column prop="date" label="是否大件" width="180"> </el-table-column>
  475. <el-table-column prop="date" label="是否拆装" width="180"> </el-table-column>
  476. <el-table-column prop="date" label="件数" width="180"> </el-table-column>
  477. <el-table-column prop="date" label="操作" width="180">
  478. <template slot-scope="scope">
  479. <el-button type="text" @click="changeAdanceOrder(scope.row)">选择订单</el-button>
  480. </template>
  481. </el-table-column>
  482. </el-table>
  483. </el-dialog>
  484. </div>
  485. </template>
  486. <style>
  487. /*.box-shadow .el-button--medium{*/
  488. /* font-size: 18px;*/
  489. /*}*/
  490. </style>
  491. <script>
  492. import CashCloth from './component/cashCloth'
  493. import payStatusPopup from '@/components/payStatusPopup'
  494. import { listClothItem, getClothItem, delClothItem, addClothItem, updateClothItem, updateClothItemStatus } from '@/api/order/clothItem'
  495. import { uploadBase64OSS, uploadOSS, saveOrderClothPics } from '@/api/upload'
  496. import { getOrderStatusByOrderNo } from '../../../api/order/cloth'
  497. import { allList } from '@/api/core/clothType'
  498. import { allClothItem } from '../../../api/core/clothItem'
  499. import { allClothColor } from '../../../api/core/color'
  500. import { allClothFlaw } from '@/api/core/flaw'
  501. import { allClothFlawType } from '@/api/core/flawType'
  502. import { allClothAdjunct } from '../../../api/cloth/adjunct'
  503. import { findUserByPhoneNumber } from '@/api/app/user'
  504. import { listWashModePriceByClothId } from '../../../api/cloth/price'
  505. import { allClothSpeed } from '../../../api/cloth/speed'
  506. import { allClothCraft } from '../../../api/cloth/craft'
  507. import { collectCloth, getInfoByOrderNo, clothOrderPay } from '../../../api/order/cloth'
  508. import { allBrand } from '../../../api/cloth/brand'
  509. import { getCouponItemlistByAppUserId, getDiscountByStoreId } from '../../../api/coupon/item'
  510. import { add, multi, minute, sub } from '../../../utils/math'
  511. import request from '@/utils/request'
  512. export default {
  513. name: 'CollectCloth',
  514. components: { CashCloth, payStatusPopup },
  515. dicts: ['sys_yes_no', 'cloth_type', 'cloth_send_type'],
  516. data() {
  517. return {
  518. uploadAction: `${process.env.VUE_APP_BASE_API}` + '/common/uploadOSS',
  519. appUserInfo: null,
  520. checkOrderStatusNum: 0,
  521. checkOrderIntervalId: null,
  522. addClothActiveTab: 0,
  523. defaultList: {
  524. type: '',
  525. clothTypes: [],
  526. item: '',
  527. clothItems: [],
  528. color: '',
  529. clothColors: [],
  530. brand: '',
  531. clothBrands: [],
  532. flaw: '',
  533. clothFlaws: [],
  534. adjunct: '',
  535. clothAdjuncts: []
  536. },
  537. clothBrands: [],
  538. clothTypes: [],
  539. clothItems: [],
  540. clothColors: [],
  541. clothFlawTypes: [],
  542. clothFlaws: [],
  543. clothAdjuncts: [],
  544. clothWashModes: [],
  545. clothCrafts: [],
  546. clothSpeeds: [],
  547. orderForm: {
  548. isSpecial: 'N',
  549. isAppointment: 'N',
  550. authCode: '',
  551. payType: '3'
  552. },
  553. // 总条数
  554. total: 0,
  555. // 洗衣订单衣服明细表格数据
  556. orderClothItemDTOS: [],
  557. selectClothItemIndex: -1,
  558. selectCoupons: [],
  559. // 弹出层标题
  560. title: '',
  561. // 是否显示弹出层
  562. open: false,
  563. isUpdateClothItem: false,
  564. //衣服特殊价格设置
  565. setClothSpecialPriceOpen: false,
  566. clothSpecialForm: {},
  567. //衣服附件相关
  568. addClothAdjunctOpen: false,
  569. addClothAdjuncts: [],
  570. //衣服照片相关
  571. addClothPicOpen: false,
  572. addClothPics: null,
  573. //衣服洗衣方式
  574. addClothWashModeOpen: false,
  575. //衣服备注
  576. addClothRemarkOpen: false,
  577. clothRemark: '',
  578. setClothDefaultPriceOpen: false,
  579. defaultPrice: 0,
  580. confirmPayOpen: false,
  581. confirmCouponTabIndex: '0',
  582. confirmDeductTabIndex: '0',
  583. setCouponOpen: false, //是否选择优惠券
  584. discountCouponVOS: [], //可选择的折扣券
  585. deductCouponVOS: [], //可选择的抵扣券
  586. changeDiscountCouponIndex: -1,
  587. changeDiscountCouponOpen: false,
  588. changeDiscountCouponTitle: '',
  589. changeDiscountCouponSelectCloths: [],
  590. changeDiscountCouponCanSelectCloths: [],
  591. // 查询参数
  592. queryParams: {},
  593. // 表单参数
  594. form: {},
  595. // 表单校验
  596. rules: {},
  597. photographType: false,
  598. photographimgList: [],
  599. previewimgList: [],
  600. uploadList: [],
  601. photoLoading: true,
  602. clothId: null,
  603. stream: null,
  604. fileType: ['png', 'jpg', 'jpeg'],
  605. videoType: true,
  606. photoType: false,
  607. collectClothDetail: null,
  608. showAdvanceOrder: false,
  609. advanceOrderList: []
  610. }
  611. },
  612. mounted() {
  613. if (process.env.ENV != 'production') {
  614. window.vue = this
  615. }
  616. },
  617. created() {
  618. allClothCraft().then((res) => {
  619. this.clothCrafts = res.data
  620. this.clothCrafts.forEach((item) => {
  621. item.defaultPrice = 20
  622. })
  623. })
  624. allClothSpeed().then((speedRes) => {
  625. this.clothSpeeds = speedRes.data
  626. })
  627. },
  628. methods: {
  629. // 添加衣物过滤数据
  630. searchCloth(k1, k2) {
  631. if (!this.defaultList[k1]) {
  632. this[k2] = this.defaultList[k2]
  633. } else {
  634. this[k2] = this.defaultList[k2].filter((item) => {
  635. return item.name.indexOf(this.defaultList[k1]) > -1
  636. })
  637. }
  638. },
  639. // 切换衣服瑕疵分页
  640. changeClothTab() {
  641. this.defaultList.flaw = ''
  642. this.clothFlaws = this.defaultList.clothFlaws
  643. },
  644. // 上传前校检格式和大小
  645. handleBeforeUpload(file) {
  646. // 校检文件类型
  647. if (this.fileType) {
  648. const fileName = file.name.split('.')
  649. const fileExt = fileName[fileName.length - 1]
  650. const isTypeOk = this.fileType.indexOf(fileExt) >= 0
  651. if (!isTypeOk) {
  652. this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join('/')}格式文件!`)
  653. return false
  654. }
  655. }
  656. // 校检文件大小
  657. const isLt = file.size / 1024 / 1024 < 3
  658. if (!isLt) {
  659. this.$message.error(`上传文件大小不能超过 3MB!`)
  660. return false
  661. }
  662. this.$modal.loading('正在上传文件,请稍候...')
  663. return true
  664. },
  665. handleUploadSuccess(res, file) {
  666. if (res.code === 200) {
  667. this.previewimgList.push(res.data.src)
  668. this.uploadList.push({ name: res.data.fileName, url: res.data.src })
  669. this.uploadedSuccessfully()
  670. } else {
  671. this.$modal.closeLoading()
  672. this.$modal.msgError(res.msg)
  673. this.$refs.fileUpload.handleRemove(file)
  674. this.uploadedSuccessfully()
  675. }
  676. },
  677. handleUploadError() {
  678. this.$modal.msgError('上传文件失败,请重试')
  679. this.$modal.closeLoading()
  680. },
  681. // 上传结束处理
  682. uploadedSuccessfully() {
  683. if (this.uploadList.length) {
  684. // this.fileList = this.fileList.concat(this.uploadList);
  685. this.uploadList.forEach((item) => {
  686. this.photographimgList.push({
  687. src: item.url,
  688. fileName: item.fileName,
  689. type: true
  690. })
  691. })
  692. this.uploadList = []
  693. this.$modal.closeLoading()
  694. this.getuploadState()
  695. }
  696. },
  697. //根据上传文件状态判断显示
  698. getuploadState() {
  699. // 初始状态值
  700. let state = true
  701. // 判断数组中的所有元素是否都为true
  702. if (this.photographimgList.every((item) => item.type === true)) {
  703. state = false
  704. } else {
  705. state = true
  706. }
  707. return state
  708. },
  709. // 取消按钮
  710. cancel() {
  711. this.confirmPayOpen = false
  712. this.reset()
  713. },
  714. // 表单重置
  715. reset() {
  716. this.form = {
  717. orderClothCraftDTOS: [], //衣服工艺
  718. orderClothAdjunctDTOS: [],
  719. orderClothTypeDTOS: [],
  720. clothTypeKeys: [],
  721. specialPrice: 0,
  722. clothSpeedMultiple: 1,
  723. picNum: 0,
  724. isCustomPrice: 'N',
  725. remark: '',
  726. defaultPrice: 0
  727. }
  728. },
  729. /** 搜索按钮操作 */
  730. handleQuery() {
  731. this.queryParams.pageNum = 1
  732. },
  733. /** 重置按钮操作 */
  734. resetQuery() {
  735. this.resetForm('queryForm')
  736. this.handleQuery()
  737. },
  738. /** 新增按钮操作 */
  739. handleAdd() {
  740. allList().then((res) => {
  741. this.defaultList.type = ''
  742. this.defaultList.clothTypes = res.data
  743. this.clothTypes = res.data
  744. this.reset()
  745. this.selectClothItemIndex = -1
  746. this.addClothActiveTab = 0
  747. this.isUpdateClothItem = false
  748. this.open = true
  749. this.title = '添加衣物'
  750. })
  751. },
  752. /** 修改按钮操作 */
  753. handleUpdate(row) {
  754. this.reset()
  755. const id = row.id || this.ids
  756. getClothItem(id).then((response) => {
  757. this.form = response.data
  758. this.open = true
  759. this.title = '编辑衣物信息'
  760. })
  761. },
  762. initOrderList(e) {
  763. console.log('sssss', e)
  764. this.orderClothItemDTOS = e.concat()
  765. },
  766. onPaySuccess(orderInfo) {
  767. this.confirmPayOpen = false
  768. console.log('res', orderInfo)
  769. if (orderInfo.payTimeType == '0') {
  770. //第三方支付
  771. console.log('第三方支付')
  772. this.$refs.payStatusPopup.open(3, orderInfo, this.appUserInfo)
  773. // this.checkOrderStatusNum = 0
  774. // if (this.checkOrderIntervalId) {
  775. // clearInterval(this.checkOrderIntervalId)
  776. // }
  777. // this.checkOrderIntervalId = setInterval(() => {
  778. // this.intervalCheckOrderStatus(orderInfo.orderNo)
  779. // }, 4000)
  780. } else {
  781. this.$refs.payStatusPopup.open(1, orderInfo)
  782. this.orderClothItemDTOS = []
  783. this.queryParams = {}
  784. this.appUserInfo = null
  785. }
  786. },
  787. handelPaySuccess() {
  788. this.orderClothItemDTOS = []
  789. this.queryParams = {}
  790. this.appUserInfo = null
  791. },
  792. intervalCheckOrderStatus(orderno) {
  793. getOrderStatusByOrderNo({ orderNo: orderno }).then((response) => {
  794. if (this.checkOrderStatusNum > 15) {
  795. clearInterval(this.checkOrderIntervalId)
  796. return
  797. }
  798. if (response.data == '4') {
  799. return
  800. }
  801. if (response.data == '100') {
  802. //已取消
  803. this.$notify.error({
  804. title: '支付失败',
  805. message: '支付超时或客户已取消支付'
  806. })
  807. clearInterval(this.checkOrderIntervalId)
  808. return
  809. }
  810. this.$notify({
  811. title: '支付成功',
  812. message: '客户已成功支付订单',
  813. type: 'success'
  814. })
  815. this.pointerType = true
  816. clearInterval(this.checkOrderIntervalId)
  817. })
  818. },
  819. /** 关闭按钮 */
  820. close() {
  821. const obj = { path: '/workbench/collectCloth' }
  822. this.$tab.closeOpenPage(obj)
  823. },
  824. /** 删除按钮操作 */
  825. handleDelete(row) {
  826. const ids = row.id || this.ids
  827. this.$modal
  828. .confirm('是否确认删除洗衣订单衣服明细编号为"' + ids + '"的数据项?')
  829. .then(function () {
  830. return delClothItem(ids)
  831. })
  832. .then(() => {
  833. this.getList()
  834. this.$modal.msgSuccess('删除成功')
  835. })
  836. .catch(() => {})
  837. },
  838. checkClose(done) {
  839. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  840. .then(function () {
  841. done()
  842. })
  843. .then(() => {})
  844. .catch(() => {})
  845. },
  846. onClothTypeSelect(id) {
  847. allClothItem({ clothTypeId: id }).then((res) => {
  848. this.defaultList.item = ''
  849. this.defaultList.clothItems = res.data
  850. this.clothItems = res.data
  851. this.addClothActiveTab = 1
  852. })
  853. },
  854. onClothItemSelect(index) {
  855. for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
  856. var orderClothTypeDTO = { orderClothTypeCode: this.form.clothTypeKeys[i] }
  857. if (this.form.clothTypeKeys[i] == '1') {
  858. orderClothTypeDTO.clothTypeName = '加厚'
  859. orderClothTypeDTO.clothTypePrice = this.clothItems[index].plusPrice
  860. }
  861. if (this.form.clothTypeKeys[i] == '2') {
  862. orderClothTypeDTO.clothTypeName = '羊绒'
  863. orderClothTypeDTO.clothTypePrice = this.clothItems[index].silkPrice
  864. }
  865. if (this.form.clothTypeKeys[i] == '3') {
  866. orderClothTypeDTO.clothTypeName = '真丝'
  867. orderClothTypeDTO.clothTypePrice = this.clothItems[index].sheepPrice
  868. }
  869. if (this.form.clothTypeKeys[i] == '4') {
  870. orderClothTypeDTO.clothTypeName = '儿童'
  871. orderClothTypeDTO.clothTypePrice = this.clothItems[index].childPrice
  872. }
  873. this.form.orderClothTypeDTOS.push(orderClothTypeDTO)
  874. }
  875. this.form.clothWashModeId = this.clothItems[index].washId
  876. this.form.clothWashModeName = this.clothItems[index].washName
  877. if (this.isUpdateClothItem) {
  878. //修改已选择的衣服
  879. this.form.clothItemId = this.clothItems[index].id
  880. this.form = { ...this.form, ...this.clothItems[index] }
  881. this.form.isCustomPrice = 'N'
  882. this.orderClothItemDTOS[this.selectClothItemIndex] = this.form
  883. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  884. for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
  885. if (this.form.clothTypeKeys[i] == '1') {
  886. this.form.defaultPrice += this.clothItems[index].plusPrice
  887. }
  888. if (this.form.clothTypeKeys[i] == '2') {
  889. this.form.defaultPrice += this.clothItems[index].silkPrice
  890. }
  891. if (this.form.clothTypeKeys[i] == '3') {
  892. this.form.defaultPrice += this.clothItems[index].sheepPrice
  893. }
  894. if (this.form.clothTypeKeys[i] == '4') {
  895. this.form.defaultPrice += this.clothItems[index].childPrice
  896. }
  897. }
  898. this.open = false
  899. this.$forceUpdate()
  900. } else {
  901. allClothColor().then((res) => {
  902. this.defaultList.color = ''
  903. this.defaultList.clothColors = res.data
  904. this.clothColors = res.data
  905. this.form.clothItemId = this.clothItems[index].id
  906. this.form = { ...this.form, ...this.clothItems[index] }
  907. for (let i = 0; i < this.form.clothTypeKeys.length; i++) {
  908. if (this.form.clothTypeKeys[i] == '1') {
  909. this.form.defaultPrice += this.clothItems[index].plusPrice
  910. }
  911. if (this.form.clothTypeKeys[i] == '2') {
  912. this.form.defaultPrice += this.clothItems[index].silkPrice
  913. }
  914. if (this.form.clothTypeKeys[i] == '3') {
  915. this.form.defaultPrice += this.clothItems[index].sheepPrice
  916. }
  917. if (this.form.clothTypeKeys[i] == '4') {
  918. this.form.defaultPrice += this.clothItems[index].childPrice
  919. }
  920. }
  921. this.addClothActiveTab = 2
  922. })
  923. }
  924. },
  925. onClothColorSelect(index) {
  926. this.clothColors[index].isSelect = this.clothColors[index].isSelect ? false : true
  927. this.$forceUpdate()
  928. },
  929. onClothBrandSelect(id) {
  930. var brand = this.clothBrands.find((item) => item.id == id)
  931. this.form.clothBrandId = id
  932. this.form.clothBrandName = brand.name
  933. if (this.isUpdateClothItem) {
  934. this.orderClothItemDTOS[this.selectClothItemIndex].clothBrandId = id
  935. this.orderClothItemDTOS[this.selectClothItemIndex].clothBrandName = brand.name
  936. this.open = false
  937. } else {
  938. allClothFlawType().then((res) => {
  939. this.clothFlawTypes = res.data
  940. allClothFlaw().then((res1) => {
  941. this.defaultList.flaw = ''
  942. this.defaultList.clothFlaws = res1.data
  943. this.clothFlaws = res1.data
  944. this.addClothActiveTab = 4
  945. })
  946. })
  947. }
  948. },
  949. addClothItemConfirm() {
  950. if (this.addClothActiveTab == 2) {
  951. //选择颜色
  952. var clothColorDTOS = []
  953. this.clothColors.forEach((item) => {
  954. if (item.isSelect) {
  955. clothColorDTOS.push({ clothColorId: item.id, clothColorName: item.name })
  956. }
  957. })
  958. if (clothColorDTOS.length == 0) {
  959. this.$message.error('请先选择颜色')
  960. return
  961. }
  962. this.form.orderClothColorDTOS = clothColorDTOS
  963. if (this.isUpdateClothItem) {
  964. //修改已选择的衣服
  965. this.orderClothItemDTOS[this.selectClothItemIndex] = this.form
  966. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  967. this.open = false
  968. this.$forceUpdate()
  969. } else {
  970. allBrand().then((res) => {
  971. res.data.push({
  972. id: '0',
  973. name: '无'
  974. })
  975. this.defaultList.brand = ''
  976. this.defaultList.clothBrands = res.data
  977. this.clothBrands = res.data
  978. this.addClothActiveTab = 3
  979. })
  980. }
  981. } else if (this.addClothActiveTab == 4) {
  982. //选择瑕疵
  983. var clothFlawDTOS = []
  984. this.clothFlaws.forEach((item) => {
  985. if (item.isSelect) {
  986. clothFlawDTOS.push({ clothFlawId: item.id, clothFlawName: item.name })
  987. }
  988. })
  989. if (clothFlawDTOS.length == 0) {
  990. this.$message.error('请先选择瑕疵')
  991. return
  992. }
  993. this.form.orderClothFlawDTOS = clothFlawDTOS
  994. if (this.isUpdateClothItem) {
  995. this.orderClothItemDTOS[this.selectClothItemIndex] = this.form
  996. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  997. this.open = false
  998. this.$forceUpdate()
  999. } else {
  1000. // this.orderClothItemDTOS.push(this.form)
  1001. // console.log(this.orderClothItemDTOS)
  1002. // this.open = false
  1003. allClothAdjunct().then((res) => {
  1004. this.defaultList.clothAdjuncts = res.data
  1005. this.defaultList.adjunct = ''
  1006. this.clothAdjuncts = res.data
  1007. this.addClothActiveTab = 5
  1008. let index = this.orderClothItemDTOS.length
  1009. this.selectClothItemIndex = index
  1010. this.addClothAdjuncts = []
  1011. this.$forceUpdate()
  1012. })
  1013. }
  1014. } else if (this.addClothActiveTab == 5) {
  1015. this.orderClothItemDTOS.push(this.form)
  1016. this.addClothAdjunctSubmit()
  1017. this.open = false
  1018. }
  1019. },
  1020. onClothFlawSelect(index) {
  1021. this.clothFlaws[index].isSelect = this.clothFlaws[index].isSelect ? false : true
  1022. this.$forceUpdate()
  1023. },
  1024. //条码搜索用户
  1025. qrcodeSearchUser() {},
  1026. //搜索用户
  1027. searchUser() {
  1028. this.$refs['queryForm'].validate((valid) => {
  1029. if (valid) {
  1030. findUserByPhoneNumber(this.queryParams).then((res) => {
  1031. this.appUserInfo = res.data
  1032. // this.getAdvanceOrder(res.data.id)
  1033. })
  1034. }
  1035. })
  1036. },
  1037. getAdvanceOrder(id) {
  1038. this.showAdvanceOrder = true
  1039. request({
  1040. url: '/mapi/order/cloth/list',
  1041. method: 'get',
  1042. params: {
  1043. pageNum: 1,
  1044. pageSize: 100,
  1045. user: id
  1046. }
  1047. }).then((data) => {
  1048. if (data && data.code === 200) {
  1049. console.log('预约订单', data)
  1050. // this.pagination.total = data.total
  1051. // if (this.renderFun) {
  1052. // this.renderFun(data.rows, data)
  1053. // } else {
  1054. // this.data = data.rows
  1055. // }
  1056. } else {
  1057. this.$message.error(data.msg)
  1058. }
  1059. })
  1060. },
  1061. changeAdanceOrder(e) {
  1062. // orderForm.isAppointment orderForm.orderNo
  1063. this.orderForm.isAppointment = 'Y'
  1064. this.orderForm.orderForm.orderNo = e.orderNo
  1065. },
  1066. handleAddClothFlaw(index) {
  1067. allClothAdjunct().then((res) => {
  1068. this.defaultList.clothAdjuncts = res.data
  1069. this.defaultList.adjunct = ''
  1070. this.clothAdjuncts = res.data
  1071. this.addClothAdjunctOpen = true
  1072. this.selectClothItemIndex = index
  1073. this.addClothAdjuncts = this.orderClothItemDTOS[index].orderClothAdjunctDTOS.concat()
  1074. this.$forceUpdate()
  1075. })
  1076. },
  1077. handleAddClothPics(index) {
  1078. this.addClothPicOpen = true
  1079. this.selectClothItemIndex = index
  1080. this.addClothPics = this.orderClothItemDTOS[index].pics
  1081. },
  1082. handleClose(done) {
  1083. this.$confirm('确认关闭?')
  1084. .then((_) => {
  1085. done()
  1086. })
  1087. .catch((_) => {})
  1088. },
  1089. onClothAdjunctSelect(item) {
  1090. var isContains = false
  1091. for (let i = 0; i < this.addClothAdjuncts.length; i++) {
  1092. if (this.addClothAdjuncts[i].adjunctId == item.id) {
  1093. if (this.addClothAdjuncts[i].num >= 999) {
  1094. return
  1095. }
  1096. this.addClothAdjuncts[i].num++
  1097. isContains = true
  1098. break
  1099. }
  1100. }
  1101. if (!isContains) {
  1102. this.addClothAdjuncts.push({ adjunctId: item.id, num: 1, adjunctName: item.name })
  1103. }
  1104. },
  1105. removeClothAdjunct(index) {
  1106. this.addClothAdjuncts.splice(index, 1)
  1107. },
  1108. addClothAdjunctSubmit() {
  1109. console.log(this.orderClothItemDTOS[this.selectClothItemIndex])
  1110. this.orderClothItemDTOS[this.selectClothItemIndex].orderClothAdjunctDTOS = this.addClothAdjuncts.concat()
  1111. this.addClothAdjunctOpen = false
  1112. },
  1113. updateClothItem(index, tabIndex) {
  1114. if (tabIndex == 0) {
  1115. allList().then((res) => {
  1116. this.defaultList.type = ''
  1117. this.defaultList.clothTypes = res.data
  1118. this.clothTypes = res.data
  1119. this.selectClothItemIndex = index
  1120. this.form = { ...this.orderClothItemDTOS[index] }
  1121. this.isUpdateClothItem = true
  1122. this.addClothActiveTab = tabIndex
  1123. this.open = true
  1124. this.title = '修改衣物信息'
  1125. })
  1126. }
  1127. if (tabIndex == 2) {
  1128. allClothColor().then((res) => {
  1129. this.defaultList.color = ''
  1130. this.defaultList.clothColors = res.data
  1131. this.clothColors = res.data
  1132. this.selectClothItemIndex = index
  1133. this.form = { ...this.orderClothItemDTOS[index] }
  1134. this.isUpdateClothItem = true
  1135. this.addClothActiveTab = tabIndex
  1136. this.open = true
  1137. this.title = '修改衣物信息'
  1138. })
  1139. }
  1140. if (tabIndex == 3) {
  1141. allBrand().then((res) => {
  1142. this.defaultList.brand = ''
  1143. this.defaultList.clothBrands = res.data
  1144. this.clothBrands = res.data
  1145. this.selectClothItemIndex = index
  1146. this.form = { ...this.orderClothItemDTOS[index] }
  1147. this.isUpdateClothItem = true
  1148. this.addClothActiveTab = tabIndex
  1149. this.open = true
  1150. this.title = '修改衣服品牌'
  1151. })
  1152. }
  1153. if (tabIndex == 4) {
  1154. //修改瑕疵
  1155. allClothFlawType().then((res) => {
  1156. this.clothFlawTypes = res.data
  1157. allClothFlaw().then((res1) => {
  1158. this.defaultList.flaw = ''
  1159. this.defaultList.clothFlaws = res1.data
  1160. this.clothFlaws = res1.data
  1161. this.selectClothItemIndex = index
  1162. this.form = { ...this.orderClothItemDTOS[index] }
  1163. this.isUpdateClothItem = true
  1164. this.addClothActiveTab = tabIndex
  1165. this.open = true
  1166. this.title = '修改衣物信息'
  1167. })
  1168. })
  1169. }
  1170. },
  1171. addClothPicSubmit() {
  1172. this.orderClothItemDTOS[this.selectClothItemIndex].pics = this.addClothPics
  1173. if (this.isEmpty(this.addClothPics)) {
  1174. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = 0
  1175. } else {
  1176. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = this.addClothPics.split(',').length
  1177. }
  1178. // this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  1179. this.addClothPicOpen = false
  1180. // this.$forceUpdate()
  1181. // console.log(this.orderClothItemDTOS)
  1182. },
  1183. //复制衣服
  1184. handleCopyClothItem(index) {
  1185. this.orderClothItemDTOS.push({ ...this.orderClothItemDTOS[index] })
  1186. },
  1187. //修改洗衣方式
  1188. changeClothWashMode(index) {
  1189. listWashModePriceByClothId({ clothId: this.orderClothItemDTOS[index].id }).then((res) => {
  1190. this.clothWashModes = res.data
  1191. this.addClothWashModeOpen = true
  1192. this.selectClothItemIndex = index
  1193. })
  1194. },
  1195. //洗衣方式被选择
  1196. onClothWashModeSelect(index) {
  1197. this.orderClothItemDTOS[this.selectClothItemIndex].clothWashModeName = this.clothWashModes[index].washModeName
  1198. this.orderClothItemDTOS[this.selectClothItemIndex].clothWashModeId = this.clothWashModes[index].washModeId
  1199. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice = this.clothWashModes[index].price
  1200. for (let i = 0; i < this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys.length; i++) {
  1201. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '1') {
  1202. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].plusPrice
  1203. }
  1204. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '2') {
  1205. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].silkPrice
  1206. }
  1207. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '3') {
  1208. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].sheepPrice
  1209. }
  1210. if (this.orderClothItemDTOS[this.selectClothItemIndex].clothTypeKeys[i] == '4') {
  1211. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice += this.orderClothItemDTOS[this.selectClothItemIndex].childPrice
  1212. }
  1213. }
  1214. this.addClothWashModeOpen = false
  1215. },
  1216. handleRemarkClothItem(index) {
  1217. this.selectClothItemIndex = index
  1218. this.clothRemark = this.orderClothItemDTOS[this.selectClothItemIndex].remark
  1219. this.addClothRemarkOpen = true
  1220. },
  1221. addClothRemarkSubmit() {
  1222. this.orderClothItemDTOS[this.selectClothItemIndex].remark = this.clothRemark
  1223. this.addClothRemarkOpen = false
  1224. },
  1225. //特殊价格处理
  1226. changeClothSpecialPriceEvent(index) {
  1227. this.selectClothItemIndex = index
  1228. this.clothSpecialForm = {}
  1229. var clothCrafts = []
  1230. this.clothCrafts.forEach((item) => {
  1231. var isSet = false
  1232. for (let i = 0; i < this.orderClothItemDTOS[this.selectClothItemIndex].orderClothCraftDTOS.length; i++) {
  1233. if (this.orderClothItemDTOS[this.selectClothItemIndex].orderClothCraftDTOS[i].clothCraftId == item.id) {
  1234. isSet = true
  1235. clothCrafts.push({
  1236. clothCraftId: item.id,
  1237. clothCraftName: item.craftName,
  1238. price: this.orderClothItemDTOS[this.selectClothItemIndex].orderClothCraftDTOS[i].price,
  1239. isSelect: true
  1240. })
  1241. break
  1242. }
  1243. }
  1244. if (!isSet) {
  1245. clothCrafts.push({
  1246. clothCraftId: item.id,
  1247. clothCraftName: item.craftName,
  1248. price: item.defaultPrice,
  1249. isSelect: false
  1250. })
  1251. }
  1252. })
  1253. var clothSpeeds = []
  1254. this.clothSpeeds.forEach((item) => {
  1255. var clothSpeed = { ...item }
  1256. clothSpeed.isSelect = clothSpeed.id == this.orderClothItemDTOS[this.selectClothItemIndex].clothSpeedId
  1257. clothSpeeds.push(clothSpeed)
  1258. })
  1259. this.clothSpecialForm.clothCrafts = clothCrafts
  1260. this.clothSpecialForm.clothSpeeds = clothSpeeds
  1261. this.clothSpecialForm.isHedging = this.orderClothItemDTOS[this.selectClothItemIndex].isHedging == 'Y'
  1262. this.clothSpecialForm.hedgingPrice = this.orderClothItemDTOS[this.selectClothItemIndex].hedgingPrice
  1263. this.clothSpecialForm.clothSpeedId = this.orderClothItemDTOS[this.selectClothItemIndex].clothSpeedId
  1264. this.clothSpecialForm.clothSpeedName = this.orderClothItemDTOS[this.selectClothItemIndex].clothSpeedName
  1265. this.setClothSpecialPriceOpen = true
  1266. console.log(this.clothSpecialForm)
  1267. },
  1268. changeClothDefaultPriceEvent(index) {
  1269. this.selectClothItemIndex = index
  1270. this.defaultPrice = this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice || null
  1271. this.setClothDefaultPriceOpen = true
  1272. },
  1273. /**
  1274. * 提交默认价格
  1275. */
  1276. setClothDefaultPriceSubmit() {
  1277. if (this.isEmpty(this.defaultPrice)) {
  1278. this.$message.error('请输入价格')
  1279. return
  1280. }
  1281. this.orderClothItemDTOS[this.selectClothItemIndex].defaultPrice = this.defaultPrice
  1282. this.orderClothItemDTOS[this.selectClothItemIndex].isCustomPrice = 'Y'
  1283. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  1284. this.setClothDefaultPriceOpen = false
  1285. },
  1286. changeClothCraftSelect() {
  1287. console.log(this.clothSpecialForm)
  1288. this.$forceUpdate()
  1289. },
  1290. changeClothHedgingSelect(index) {
  1291. if (this.clothSpecialForm.isHedging) {
  1292. this.clothSpecialForm.clothSpeeds[1].isSelect = true
  1293. for (let i = 2; i < this.clothSpecialForm.clothSpeeds.length; i++) {
  1294. this.clothSpecialForm.clothSpeeds[i].isSelect = false
  1295. }
  1296. }
  1297. this.$forceUpdate()
  1298. },
  1299. changeClothSpeedSelect(index) {
  1300. if (index == 1 && this.clothSpecialForm.isHedging) {
  1301. this.clothSpecialForm.clothSpeeds[1].isSelect = true
  1302. } else {
  1303. if (this.clothSpecialForm.isHedging) {
  1304. this.clothSpecialForm.isHedging = false
  1305. }
  1306. for (let i = 1; i < this.clothSpecialForm.clothSpeeds.length; i++) {
  1307. if (i != index) {
  1308. this.clothSpecialForm.clothSpeeds[i].isSelect = false
  1309. }
  1310. }
  1311. }
  1312. this.$forceUpdate()
  1313. },
  1314. addClothSpecialSubmit() {
  1315. var param = {}
  1316. param.orderClothCraftDTOS = []
  1317. for (let i = 0; i < this.clothSpecialForm.clothCrafts.length; i++) {
  1318. if (this.clothSpecialForm.clothCrafts[i].isSelect) {
  1319. if (this.isEmpty(this.clothSpecialForm.clothCrafts[i].price)) {
  1320. this.$message.error(this.clothSpecialForm.clothCrafts[i].clothCraftName + '价格未设置')
  1321. return
  1322. }
  1323. param.orderClothCraftDTOS.push(this.clothSpecialForm.clothCrafts[i])
  1324. }
  1325. }
  1326. param.isHedging = this.clothSpecialForm.isHedging ? 'Y' : 'N'
  1327. param.hedgingPrice = this.clothSpecialForm.hedgingPrice
  1328. var isHighSpeed = false
  1329. for (let i = 1; i < this.clothSpecialForm.clothSpeeds.length; i++) {
  1330. if (this.clothSpecialForm.clothSpeeds[i].isSelect) {
  1331. isHighSpeed = true
  1332. param.clothSpeedId = this.clothSpecialForm.clothSpeeds[i].id
  1333. param.clothSpeedName = this.clothSpecialForm.clothSpeeds[i].name
  1334. param.clothSpeedMultiple = this.clothSpecialForm.clothSpeeds[i].multiple
  1335. break
  1336. }
  1337. }
  1338. if (!isHighSpeed) {
  1339. param.clothSpeedId = this.clothSpecialForm.clothSpeeds[0].id
  1340. param.clothSpeedMultiple = this.clothSpecialForm.clothSpeeds[0].multiple
  1341. }
  1342. this.orderClothItemDTOS[this.selectClothItemIndex] = { ...this.orderClothItemDTOS[this.selectClothItemIndex], ...param }
  1343. console.log(this.orderClothItemDTOS)
  1344. this.setClothSpecialPriceOpen = false
  1345. this.orderClothItemDTOS = this.orderClothItemDTOS.concat()
  1346. this.$forceUpdate()
  1347. },
  1348. async handleConfirmPay() {
  1349. if (this.orderClothItemDTOS.length == 0) {
  1350. this.$message.error('请先添加衣服')
  1351. return
  1352. }
  1353. if (!this.appUserInfo) {
  1354. this.$message.error('请先选择客户')
  1355. return
  1356. }
  1357. if (this.orderForm.isAppointment == 'Y' && this.isEmpty(this.orderForm.orderNo)) {
  1358. this.$message.error('请先输入预约订单号')
  1359. return
  1360. }
  1361. // if (!this.orderForm.sendClothWay) {
  1362. // this.$message.error('请先选取衣方式')
  1363. // return
  1364. // }
  1365. if (this.orderForm.isAppointment == 'Y') {
  1366. var res = await getInfoByOrderNo({ orderNo: this.orderForm.orderNo, appUserId: this.appUserInfo.id })
  1367. if (res.data == null) {
  1368. this.$message.error('未查询到预约订单')
  1369. return
  1370. }
  1371. // this.orderForm.sendClothWay = res.data.sendClothWay
  1372. }
  1373. //
  1374. var params = { appUserId: this.appUserInfo.id, discountWay: '2' }
  1375. var clothIds = []
  1376. this.orderClothItemDTOS.forEach((item) => {
  1377. clothIds.push(item.id)
  1378. })
  1379. params.clothIds = clothIds
  1380. this.orderForm.isSpecial = 'N'
  1381. this.orderForm.authCode = ''
  1382. this.orderForm.payType = ''
  1383. getDiscountByStoreId({ appUserId: this.appUserInfo.id }).then((res) => {
  1384. this.discountCouponVOS = res.data
  1385. params.discountWay = '0'
  1386. getCouponItemlistByAppUserId(params).then((res) => {
  1387. // console.log(res.data)
  1388. // res.data.forEach(item => {
  1389. // item.isUnique = 'N'
  1390. // })
  1391. this.deductCouponVOS = res.data
  1392. this.selectCoupons = []
  1393. this.orderClothItemDTOS.forEach((item, index) => {
  1394. item.index = index
  1395. item.deductAmount = 0
  1396. item.totalPrice = this.calculateClothSpecialPrice(index) + item.defaultPrice
  1397. })
  1398. delete this.orderForm.cashDeductAmount
  1399. delete this.orderForm.discountCouponId
  1400. delete this.orderForm.discountCoupon
  1401. this.confirmPayOpen = true
  1402. })
  1403. })
  1404. },
  1405. onCouponTabChange(tab, event) {
  1406. console.log('tab.index:' + tab.index)
  1407. // if(tab.index == '1'){
  1408. // this.$refs['couponRef'].focus()
  1409. // }
  1410. },
  1411. //计算某一件衣服的优惠金额,并配置到orderClothItemDTOS中
  1412. calculateClothDiscountAmount(index) {
  1413. var cloth = this.orderClothItemDTOS[index]
  1414. cloth.deductAmount = 0
  1415. this.selectCoupons.forEach((i) => {
  1416. var selectCloth = i.orderCouponClothDTOS.find((item) => item.clothIndex == cloth.index)
  1417. if (selectCloth) {
  1418. cloth.deductAmount = cloth.deductAmount + selectCloth.deductAmount
  1419. }
  1420. })
  1421. },
  1422. //<editor-folder desc="计算相关函数"/>
  1423. calculateClothSpecialPrice(index) {
  1424. // console.log('calculateClothSpecialPrice')
  1425. var specialPrice = 0
  1426. for (let i = 0; i < this.orderClothItemDTOS[index].orderClothCraftDTOS.length; i++) {
  1427. specialPrice += this.orderClothItemDTOS[index].orderClothCraftDTOS[i].price
  1428. }
  1429. if (this.orderClothItemDTOS[index].isHedging == 'Y') {
  1430. specialPrice += this.orderClothItemDTOS[index].hedgingPrice * 0.01
  1431. }
  1432. for (let i = 0; i < this.clothSpeeds.length; i++) {
  1433. if (this.orderClothItemDTOS[index].clothSpeedId == this.clothSpeeds[i].id) {
  1434. specialPrice += this.orderClothItemDTOS[index].defaultPrice * (this.clothSpeeds[i].multiple - 1)
  1435. break
  1436. }
  1437. }
  1438. // console.log('specialPrice:' + specialPrice)
  1439. return specialPrice
  1440. },
  1441. calculateClothName(index) {
  1442. var clothName = this.orderClothItemDTOS[index].name
  1443. console.log(this.orderClothItemDTOS[index].orderClothTypeDTOS)
  1444. this.orderClothItemDTOS[index].orderClothTypeDTOS.forEach((item) => {
  1445. clothName += '【' + item.clothTypeName + '】'
  1446. })
  1447. return clothName
  1448. },
  1449. calculateTotalPrice() {
  1450. var price = 0
  1451. for (let i = 0; i < this.orderClothItemDTOS.length; i++) {
  1452. price += this.calculateClothSpecialPrice(i) + this.orderClothItemDTOS[i].defaultPrice
  1453. }
  1454. return price
  1455. },
  1456. //</editor-folder>
  1457. //打开拍照弹框 调用摄像头
  1458. async handphotograph(index) {
  1459. this.selectClothItemIndex = index
  1460. if (this.orderClothItemDTOS[index].pics) {
  1461. let imgList = this.orderClothItemDTOS[index].pics.split(',')
  1462. imgList.forEach((item) => {
  1463. this.previewimgList.push(item)
  1464. this.photographimgList.push({
  1465. type: true,
  1466. src: item
  1467. })
  1468. })
  1469. }
  1470. this.photographType = true
  1471. try {
  1472. this.stream = await navigator.mediaDevices.getUserMedia({ video: true })
  1473. this.$refs.videoElement.srcObject = this.stream
  1474. this.videoType = false
  1475. } catch (error) {
  1476. this.$modal.msgError('无法访问摄像头')
  1477. // console.error("无法访问摄像头:", error);
  1478. // this.photographType = false
  1479. }
  1480. },
  1481. //点击拍照 处理成base64
  1482. async takePhoto() {
  1483. this.photoType = true
  1484. try {
  1485. const canvas = document.createElement('canvas')
  1486. const context = canvas.getContext('2d')
  1487. canvas.width = this.$refs.videoElement.videoWidth
  1488. canvas.height = this.$refs.videoElement.videoHeight
  1489. context.drawImage(this.$refs.videoElement, 0, 0, canvas.width, canvas.height)
  1490. const imageDataUrl = canvas.toDataURL('image/jpeg')
  1491. if (this.photographimgList.length >= 9) {
  1492. this.$modal.msgError('照片仅限上传9张')
  1493. this.photoType = false
  1494. return
  1495. }
  1496. let response = await fetch(imageDataUrl)
  1497. let blob = await response.blob() // 获取图片的 Blob 对象
  1498. let file = new File([blob], 'image.jpeg', { type: blob.type })
  1499. //创建form对象
  1500. let formdata = new FormData()
  1501. //通过append向form对象添加数据
  1502. formdata.append('file', file)
  1503. uploadOSS(formdata)
  1504. .then((res) => {
  1505. this.previewimgList.push(res.data.src)
  1506. this.photographimgList.push({
  1507. type: true,
  1508. src: res.data.src
  1509. })
  1510. this.photoType = false
  1511. })
  1512. .catch(() => {
  1513. // resolve(false);
  1514. this.photoType = false
  1515. })
  1516. // 上传照片或处理imageDataUrl
  1517. // this.uploadImage(imageDataUrl); // 调用上传接口或本地处理逻辑
  1518. } catch (error) {
  1519. this.photoType = false
  1520. // console.error("拍照失败:", error);
  1521. } finally {
  1522. // this.$refs.videoElement.srcObject.getTracks().forEach((track) => track.stop());
  1523. }
  1524. },
  1525. // 关闭拍照弹框后清除视频流
  1526. hidephotograph() {
  1527. const that = this
  1528. this.$confirm('是否确认关闭当前拍照功能?', '提示', {
  1529. confirmButtonText: '确定',
  1530. cancelButtonText: '取消',
  1531. type: 'warning'
  1532. })
  1533. .then(() => {
  1534. that.photographType = false
  1535. that.photographimgList = []
  1536. that.clothId = null
  1537. if (that.stream) {
  1538. that.stream.getTracks().forEach((track) => track.stop()) // 停止访问摄像头并释放资源
  1539. that.$refs.videoElement.srcObject = null // 清除视频流对象
  1540. }
  1541. })
  1542. .catch(() => {})
  1543. },
  1544. //删除照片
  1545. btn_remove(item, index) {
  1546. const that = this
  1547. this.$confirm('是否确认删除该照片?')
  1548. .then(function () {})
  1549. .then(() => {
  1550. that.photographimgList.splice(index, 1)
  1551. that.$modal.msgSuccess('删除成功')
  1552. })
  1553. .catch(() => {})
  1554. },
  1555. //保存图片
  1556. btn_submit() {
  1557. if (this.photographimgList.length < 1) {
  1558. this.$modal.msgError('请拍照上传后保存')
  1559. return
  1560. }
  1561. const srcString = this.photographimgList.map((obj) => obj.src).join(',')
  1562. this.orderClothItemDTOS[this.selectClothItemIndex].pics = srcString
  1563. if (!this.photographimgList.length) {
  1564. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = 0
  1565. } else {
  1566. this.orderClothItemDTOS[this.selectClothItemIndex].picNum = this.photographimgList.length
  1567. }
  1568. this.$modal.msgSuccess('保存成功')
  1569. this.photographType = false
  1570. this.photographimgList = []
  1571. this.clothId = null
  1572. if (this.stream) {
  1573. this.stream.getTracks().forEach((track) => track.stop()) // 停止访问摄像头并释放资源
  1574. this.$refs.videoElement.srcObject = null // 清除视频流对象
  1575. }
  1576. }
  1577. }
  1578. }
  1579. </script>
  1580. <style scoped lang="scss">
  1581. .photo_content {
  1582. display: flex;
  1583. .video_content {
  1584. flex-shrink: 0;
  1585. width: 50%;
  1586. position: relative;
  1587. .loading {
  1588. position: absolute;
  1589. top: 0;
  1590. left: 0;
  1591. bottom: 0;
  1592. right: 0;
  1593. background-color: rgba(0, 0, 0, 0.8);
  1594. z-index: 10;
  1595. .el-button {
  1596. position: absolute;
  1597. top: 50%;
  1598. left: 50%;
  1599. transform: translate(-50%, -50%);
  1600. z-index: 15;
  1601. border: none;
  1602. color: #ffffff;
  1603. padding: 10px 20px;
  1604. }
  1605. }
  1606. .videoElement {
  1607. width: 100%;
  1608. height: auto;
  1609. }
  1610. }
  1611. .view {
  1612. flex: 1;
  1613. padding: 20px;
  1614. .btn_box {
  1615. display: flex;
  1616. .btn_upload {
  1617. margin: 0 10px;
  1618. }
  1619. }
  1620. .image_list {
  1621. margin-top: 20px;
  1622. .image_item {
  1623. display: inline-block;
  1624. margin: 0 10px 10px 0;
  1625. position: relative;
  1626. border-radius: 5px;
  1627. overflow: hidden;
  1628. .image_bottom {
  1629. position: absolute;
  1630. left: 0;
  1631. bottom: 0;
  1632. width: 100%;
  1633. // height: 25px;
  1634. // line-height: 25px;
  1635. background-color: rgba(255, 255, 255, 0.3);
  1636. text-align: center;
  1637. color: #fff;
  1638. cursor: pointer;
  1639. display: flex;
  1640. .el-button {
  1641. flex: 1;
  1642. }
  1643. }
  1644. }
  1645. }
  1646. }
  1647. }
  1648. </style>