collectCloth.vue 79 KB

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