index.vue 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="订单编号" prop="orderCodes">
  5. <div class="tag-input-container">
  6. <!-- 标签显示区域 -->
  7. <div class="tags-wrapper" @click="focusInput">
  8. <!-- 已添加的订单号标签 -->
  9. <el-tag
  10. v-for="(code, index) in queryParams.orderCodes"
  11. :key="index"
  12. closable
  13. size="small"
  14. @close="removeOrderCode(index)"
  15. class="order-tag"
  16. :class="{ 'tag-error': false }"
  17. >
  18. {{ code }}
  19. </el-tag>
  20. <!-- 输入框 -->
  21. <el-input
  22. ref="tagInput"
  23. v-model="currentInput"
  24. v-show="inputVisible || queryParams.orderCodes.length === 0"
  25. :placeholder="queryParams.orderCodes.length === 0 ? '请输入订单号,按回车或逗号分隔' : '继续输入...'"
  26. size="small"
  27. class="tag-input"
  28. @keydown.native="handleKeyDown"
  29. @keyup.native="handleKeyUp"
  30. @blur="handleInputConfirm"
  31. @focus="inputVisible = true"
  32. clearable
  33. />
  34. <!-- 添加按钮(当没有输入时显示) -->
  35. <el-button
  36. v-if="!inputVisible && queryParams.orderCodes.length > 0"
  37. class="button-new-tag"
  38. size="small"
  39. @click="showInput"
  40. icon="el-icon-plus"
  41. type="text"
  42. >
  43. 添加订单号
  44. </el-button>
  45. </div>
  46. <!-- 输入提示 -->
  47. <div class="input-tips">
  48. <span class="tip-text">
  49. 支持:回车、逗号、空格分隔 |
  50. 已添加 {{ queryParams.orderCodes.length }} 个订单号
  51. <span v-if="maxOrderCodes > 0"> (最多{{ maxOrderCodes }}个)</span>
  52. </span>
  53. </div>
  54. </div>
  55. </el-form-item>
  56. <el-form-item label="用户名称" prop="userName">
  57. <el-input
  58. v-model="queryParams.userName"
  59. placeholder="请输入用户名称"
  60. clearable
  61. size="small"
  62. @keyup.enter.native="handleQuery"
  63. />
  64. </el-form-item>
  65. <el-form-item label="用户电话" prop="userPhone">
  66. <el-input
  67. v-model="queryParams.userPhone"
  68. placeholder="请输入用户电话"
  69. clearable
  70. size="small"
  71. @keyup.enter.native="handleQuery"
  72. />
  73. </el-form-item>
  74. <el-form-item label="状态" prop="status">
  75. <el-select v-model="queryParams.status" placeholder="状态" clearable size="small">
  76. <el-option
  77. v-for="dict in statusOptions"
  78. :key="dict.dictValue"
  79. :label="dict.dictLabel"
  80. :value="dict.dictValue"
  81. />
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item label="快递单号" prop="deliverySn">
  85. <el-input
  86. v-model="queryParams.deliverySn"
  87. placeholder="请输入快递单号"
  88. clearable
  89. size="small"
  90. @keyup.enter.native="handleQuery"
  91. />
  92. </el-form-item>
  93. <el-form-item label="提交时间" prop="createTime">
  94. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  95. </el-form-item>
  96. <el-form-item label="销售公司" prop="companyId">
  97. <el-select v-model="queryParams.companyId" placeholder="销售公司" size="small" @change="getAllUserlist(queryParams.companyId)" clearable>
  98. <el-option
  99. v-for="dict in qwCompanyList"
  100. :key="dict.companyId"
  101. :label="dict.companyName"
  102. :value="dict.companyId"
  103. />
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item label="销售账号" prop="userId">
  107. <el-select v-model="queryParams.companyUserId" placeholder="销售账号" size="small" clearable>
  108. <el-option
  109. v-for="dict in companyUserNameList"
  110. :key="dict.userId"
  111. :label="dict.userName"
  112. :value="dict.userId"
  113. />
  114. </el-select>
  115. </el-form-item>
  116. <el-form-item label="企微微信" prop="companyUserName">
  117. <el-select v-model="queryParams.qwUserId" placeholder="企微微信" size="small" clearable>
  118. <el-option
  119. v-for="dict in qwUserList"
  120. :key="dict.id"
  121. :label="dict.qwUserName"
  122. :value="dict.id"
  123. />
  124. </el-select>
  125. </el-form-item>
  126. <!-- 这里就是之前添加的ERP账号下拉框 -->
  127. <el-form-item label="ERP" prop="loginAccount">
  128. <el-select v-model="queryParams.loginAccount" placeholder="ERP账号" size="small" clearable>
  129. <el-option
  130. v-for="account in erpAccountList"
  131. :key="account"
  132. :label="account"
  133. :value="account"
  134. />
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item>
  138. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  139. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  140. </el-form-item>
  141. </el-form>
  142. <el-row :gutter="10" class="mb8">
  143. <el-col :span="1.5">
  144. <el-button
  145. type="warning"
  146. plain
  147. icon="el-icon-download"
  148. size="mini"
  149. :loading="exportLoading"
  150. @click="handleExport"
  151. v-hasPermi="['his:integralOrder:export']"
  152. >导出</el-button>
  153. </el-col>
  154. <el-col :span="1.5">
  155. <el-button
  156. type="info"
  157. plain
  158. icon="el-icon-upload2"
  159. size="mini"
  160. @click="handleImportStatus"
  161. >导入订单状态</el-button>
  162. </el-col>
  163. <el-col :span="1.5">
  164. <el-tooltip content="默认erp推送手机号" placement="top">
  165. <el-button
  166. type="warning"
  167. plain
  168. icon="el-icon-phone"
  169. size="mini"
  170. @click="handleErpPhone"
  171. >推送手机号码</el-button>
  172. </el-tooltip>
  173. </el-col>
  174. <el-col :span="1.5">
  175. <el-button
  176. type="info"
  177. plain
  178. icon="el-icon-upload2"
  179. size="mini"
  180. @click="handleImport"
  181. v-hasPermi="['his:integralOrder:exportDeliver']"
  182. v-show="actName === '6'||actName === '1'"
  183. >导入发货</el-button>
  184. </el-col>
  185. <el-col :span="1.5">
  186. <el-button
  187. type="success"
  188. plain
  189. icon="el-icon-s-operation"
  190. size="mini"
  191. @click="handleDataSort"
  192. v-show="actName === '6'"
  193. >数据分拣</el-button>
  194. </el-col>
  195. <el-col :span="1.5">
  196. <el-button
  197. type="primary"
  198. plain
  199. icon="el-icon-plus"
  200. size="mini"
  201. @click="handleCreateErp"
  202. v-show="actName === '6'"
  203. >创建ERP</el-button>
  204. </el-col>
  205. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  206. </el-row>
  207. <el-tabs type="card" v-model="actName" @tab-click="handleClickX">
  208. <el-tab-pane label="全部订单" name="10"></el-tab-pane>
  209. <el-tab-pane v-for="(item,index) in statusOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  210. </el-tabs>
  211. <el-table v-loading="loading" border :data="integralOrderList" @selection-change="handleSelectionChange">
  212. <el-table-column type="selection" width="55" align="center" />
  213. <el-table-column label="订单编号" align="center" prop="orderCode" />
  214. <el-table-column label="商品信息" align="center" width="200">
  215. <template slot-scope="scope">
  216. <div style="display: flex; align-items: center; justify-content: center;">
  217. <span style="white-space: pre-line; text-align: left;">{{ scope.row.goodsName }}</span>
  218. <!-- 这里移除了num显示,因为现在goodsName已经包含数量信息 -->
  219. <!-- 如果你还需要显示其他内容,可以放在这里 -->
  220. </div>
  221. </template>
  222. </el-table-column>
  223. <el-table-column label="用户名称" align="center" prop="userName" />
  224. <el-table-column label="用户ID" align="center" prop="userId" />
  225. <el-table-column label="用户电话" align="center" prop="userPhone" />
  226. <el-table-column label="用户地址" align="center" prop="userAddress" show-overflow-tooltip />
  227. <el-table-column label="支付积分" align="center" prop="integral" />
  228. <el-table-column label="用户剩余积分" align="center" prop="userIntegral" />
  229. <el-table-column label="是否完课" align="center" prop="isCompleteCourse" />
  230. <el-table-column label="用户状态" align="center" prop="userStatus" />
  231. <el-table-column label="状态" align="center" prop="status">
  232. <template slot-scope="scope">
  233. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="快递公司编号" align="center" prop="deliveryCode" />
  237. <el-table-column label="快递名称" align="center" prop="deliveryName" />
  238. <el-table-column label="快递单号" align="center" prop="deliverySn" />
  239. <el-table-column label="发货时间" align="center" prop="deliveryTime" width="180"/>
  240. <el-table-column label="提交时间" align="center" prop="createTime" width="180"/>
  241. <el-table-column label="销售公司ID" align="center" prop="companyId" width="180"/>
  242. <el-table-column label="销售ID" align="center" prop="companyUserId" width="180"/>
  243. <el-table-column label="企业微信ID" align="center" prop="qwUserId" width="180"/>
  244. <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip/>
  245. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
  246. <template slot-scope="scope">
  247. <el-button
  248. size="mini"
  249. type="text"
  250. @click="handledetails(scope.row)"
  251. >详情
  252. </el-button>
  253. <el-button
  254. size="mini"
  255. type="text"
  256. @click="cancelOrder(scope.row.orderCode)"
  257. v-if="scope.row.status === '1'"
  258. >取消订单
  259. </el-button>
  260. </template>
  261. </el-table-column>
  262. </el-table>
  263. <pagination
  264. v-show="total>0"
  265. :total="total"
  266. :page.sync="queryParams.pageNum"
  267. :limit.sync="queryParams.pageSize"
  268. @pagination="getList"
  269. />
  270. <!-- 添加或修改积分商品订单对话框 -->
  271. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  272. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  273. <el-form-item label="订单编号" prop="orderCode">
  274. <el-input v-model="form.orderCode" placeholder="请输入订单编号" />
  275. </el-form-item>
  276. <el-form-item label="用户id" prop="userId">
  277. <el-input v-model="form.userId" placeholder="请输入用户id" />
  278. </el-form-item>
  279. <el-form-item label="用户名称" prop="userName">
  280. <el-input v-model="form.userName" placeholder="请输入用户名称" />
  281. </el-form-item>
  282. <el-form-item label="用户电话" prop="userPhone">
  283. <el-input v-model="form.userPhone" placeholder="请输入用户电话" />
  284. </el-form-item>
  285. <el-form-item label="用户地址" prop="userAddress">
  286. <el-input v-model="form.userAddress" placeholder="请输入用户地址" />
  287. </el-form-item>
  288. <el-form-item label="商品信息" prop="itemJson">
  289. <el-input v-model="form.itemJson" type="textarea" placeholder="请输入内容" />
  290. </el-form-item>
  291. <el-form-item label="支付积分" prop="integral">
  292. <el-input v-model="form.integral" placeholder="请输入支付积分" />
  293. </el-form-item>
  294. <el-form-item label="1:待发货;2:待收货;3:已完成" prop="status">
  295. <el-select v-model="form.status" placeholder="请选择1:待发货;2:待收货;3:已完成">
  296. <el-option
  297. v-for="dict in statusOptions"
  298. :key="dict.dictValue"
  299. :label="dict.dictLabel"
  300. :value="dict.dictValue"
  301. ></el-option>
  302. </el-select>
  303. </el-form-item>
  304. <el-form-item label="快递公司编号" prop="deliveryCode">
  305. <el-input v-model="form.deliveryCode" placeholder="请输入快递公司编号" />
  306. </el-form-item>
  307. <el-form-item label="快递名称" prop="deliveryName">
  308. <el-input v-model="form.deliveryName" placeholder="请输入快递名称" />
  309. </el-form-item>
  310. <el-form-item label="快递单号" prop="deliverySn">
  311. <el-input v-model="form.deliverySn" placeholder="请输入快递单号" />
  312. </el-form-item>
  313. <el-form-item label="发货时间" prop="deliveryTime">
  314. <el-date-picker clearable size="small"
  315. v-model="form.deliveryTime"
  316. type="date"
  317. value-format="yyyy-MM-dd"
  318. placeholder="选择发货时间">
  319. </el-date-picker>
  320. </el-form-item>
  321. <el-form-item label="备注" prop="remark">
  322. <el-input v-model="form.remark" placeholder="请输入备注" />
  323. </el-form-item>
  324. </el-form>
  325. <div slot="footer" class="dialog-footer">
  326. <el-button type="primary" @click="submitForm">确 定</el-button>
  327. <el-button @click="cancel">取 消</el-button>
  328. </div>
  329. </el-dialog>
  330. <el-drawer
  331. :with-header="false"
  332. size="75%"
  333. :title="show.title" :visible.sync="show.open">
  334. <integralOrderDetails ref="Details" />
  335. </el-drawer>
  336. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  337. <el-upload
  338. ref="upload"
  339. :limit="1"
  340. accept=".xlsx, .xls"
  341. :headers="upload.headers"
  342. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  343. :disabled="upload.isUploading"
  344. :on-progress="handleFileUploadProgress"
  345. :on-success="handleFileSuccess"
  346. :auto-upload="false"
  347. drag
  348. >
  349. <i class="el-icon-upload"></i>
  350. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  351. <div class="el-upload__tip text-center" slot="tip">
  352. <div class="el-upload__tip" slot="tip">
  353. </div>
  354. <span>仅允许导入xls、xlsx格式文件。</span>
  355. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
  356. </div>
  357. </el-upload>
  358. <div slot="footer" class="dialog-footer">
  359. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  360. <el-button @click="upload.open = false">取 消</el-button>
  361. </div>
  362. </el-dialog>
  363. <!-- 数据分拣弹窗 -->
  364. <el-dialog :title="erpAccountDialog.title" :visible.sync="erpAccountDialog.open" width="600px" append-to-body>
  365. <div v-loading="erpAccountDialog.loading">
  366. <el-form :model="erpAccountForm" label-width="100px">
  367. <el-form-item label="ERP账户" required>
  368. <el-select
  369. v-model="erpAccountForm.selectedAccount"
  370. placeholder="请选择ERP账户"
  371. style="width: 100%"
  372. filterable
  373. >
  374. <el-option
  375. v-for="account in erpAccountList"
  376. :key="account"
  377. :label="account"
  378. :value="account"
  379. />
  380. </el-select>
  381. </el-form-item>
  382. <el-form-item label="推送手机号">
  383. <el-select
  384. v-model="erpAccountForm.selectedPhones"
  385. multiple
  386. placeholder="请选择推送手机号,不填默认订单用户电话"
  387. style="width: 100%"
  388. filterable
  389. >
  390. <el-option
  391. v-for="phone in phoneList"
  392. :key="phone.phone"
  393. :label="phone.phone"
  394. :value="phone.phone"
  395. />
  396. </el-select>
  397. </el-form-item>
  398. </el-form>
  399. <!-- 订单统计信息 -->
  400. <div class="order-summary" v-if="orderSummary">
  401. <el-divider content-position="left">订单统计</el-divider>
  402. <el-row :gutter="20">
  403. <el-col :span="8">
  404. <div class="summary-item">
  405. <span class="label">选中订单数:</span>
  406. <span class="value">{{ orderSummary.selectedCount }}</span>
  407. </div>
  408. </el-col>
  409. <el-col :span="8">
  410. <div class="summary-item">
  411. <span class="label">总金额:</span>
  412. <span class="value">¥{{ orderSummary.totalAmount }}</span>
  413. </div>
  414. </el-col>
  415. <el-col :span="8">
  416. <div class="summary-item">
  417. <span class="label">查询条件订单:</span>
  418. <span class="value">{{ orderSummary.queryCount }}</span>
  419. </div>
  420. </el-col>
  421. </el-row>
  422. </div>
  423. </div>
  424. <div slot="footer" class="dialog-footer">
  425. <el-button @click="cancelErpAccountDialog">取 消</el-button>
  426. <el-button
  427. type="primary"
  428. @click="confirmCreateErpOrder"
  429. :disabled="!erpAccountForm.selectedAccount"
  430. :loading="erpAccountDialog.submitting"
  431. >确认</el-button>
  432. </div>
  433. </el-dialog>
  434. <!-- 推送手机号码管理弹窗 -->
  435. <el-dialog :title="erpPhone.title" :visible.sync="erpPhone.open" width="600px" append-to-body>
  436. <div style="margin-bottom: 20px;">
  437. <el-button type="primary" size="small" @click="handleAddPhone">新增手机号</el-button>
  438. </div>
  439. <el-table :data="phoneList" border style="width: 100%">
  440. <el-table-column prop="phone" label="手机号" align="center">
  441. <template slot-scope="scope">
  442. <el-input
  443. v-if="scope.row.editing"
  444. v-model="scope.row.phone"
  445. placeholder="请输入手机号"
  446. @blur="validatePhone(scope.row)"
  447. @keyup.enter.native="handleSavePhone(scope.$index)"
  448. />
  449. <span v-else>{{ scope.row.phone }}</span>
  450. </template>
  451. </el-table-column>
  452. <el-table-column label="操作" align="center" width="300">
  453. <template slot-scope="scope">
  454. <el-button
  455. v-if="scope.row.editing"
  456. type="success"
  457. size="mini"
  458. @click="handleSavePhone(scope.$index)"
  459. >保存</el-button>
  460. <el-button
  461. v-if="scope.row.editing"
  462. type="info"
  463. size="mini"
  464. @click="handleCancelEdit(scope.$index)"
  465. >取消</el-button>
  466. <el-button
  467. v-if="!scope.row.editing"
  468. type="primary"
  469. size="mini"
  470. @click="handleEditPhone(scope.$index)"
  471. >修改</el-button>
  472. <el-button
  473. type="danger"
  474. size="mini"
  475. @click="handleDeletePhone(scope.$index)"
  476. >删除</el-button>
  477. </template>
  478. </el-table-column>
  479. </el-table>
  480. <div slot="footer" class="dialog-footer">
  481. <el-button type="primary" @click="handleSavePhoneList">确 定</el-button>
  482. <el-button @click="handleCancelPhoneDialog">取 消</el-button>
  483. </div>
  484. </el-dialog>
  485. <el-dialog :title="uploadStatus.title" :visible.sync="uploadStatus.open" width="400px" append-to-body>
  486. <el-upload
  487. ref="uploadStatus"
  488. :limit="1"
  489. accept=".xlsx, .xls"
  490. :headers="uploadStatus.headers"
  491. :action="uploadStatus.url + '?updateSupport=' + upload.updateSupport"
  492. :disabled="uploadStatus.isUploading"
  493. :on-progress="handleFileUploadProgressOrder"
  494. :on-success="handleFileSuccessOrder"
  495. :auto-upload="false"
  496. drag
  497. >
  498. <i class="el-icon-upload"></i>
  499. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  500. <div class="el-upload__tip text-center" slot="tip">
  501. <div class="el-upload__tip" slot="tip">
  502. </div>
  503. <span>仅允许导入xls、xlsx格式文件。</span>
  504. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importUpdateOrderTemplate">下载模板</el-link>
  505. </div>
  506. </el-upload>
  507. <div slot="footer" class="dialog-footer">
  508. <el-button type="primary" @click="submitOrderStatusFileForm">确 定</el-button>
  509. <el-button @click="uploadStatus.open = false">取 消</el-button>
  510. </div>
  511. </el-dialog>
  512. <!-- 导入结果对话框 -->
  513. <el-dialog
  514. title="导入结果"
  515. :visible.sync="importResultDialog.open"
  516. width="80%"
  517. append-to-body
  518. :close-on-click-modal="false"
  519. >
  520. <div class="import-result-summary">
  521. <el-row :gutter="20">
  522. <el-col :span="8">
  523. <div class="summary-item success">
  524. <div class="summary-label">成功</div>
  525. <div class="summary-value">{{ importResult.successNum || 0 }}</div>
  526. </div>
  527. </el-col>
  528. <el-col :span="8">
  529. <div class="summary-item failure">
  530. <div class="summary-label">失败</div>
  531. <div class="summary-value">{{ importResult.failureNum || 0 }}</div>
  532. </div>
  533. </el-col>
  534. <el-col :span="8">
  535. <div class="summary-item total">
  536. <div class="summary-label">总计</div>
  537. <div class="summary-value">{{ (importResult.successNum || 0) + (importResult.failureNum || 0) }}</div>
  538. </div>
  539. </el-col>
  540. </el-row>
  541. </div>
  542. <el-tabs v-model="importResultTab" type="card">
  543. <el-tab-pane label="成功列表" name="success">
  544. <el-table
  545. :data="displayedSuccessList"
  546. border
  547. stripe
  548. height="400"
  549. style="width: 100%"
  550. v-loading="successListLoading"
  551. @scroll="handleSuccessListScroll"
  552. >
  553. <el-table-column type="index" label="序号" width="60" align="center" />
  554. <el-table-column prop="rowNum" label="Excel行号" width="120" align="center" />
  555. <el-table-column prop="orderCode" label="订单号" align="center" />
  556. </el-table>
  557. <div v-if="displayedSuccessList.length < importResult.successList.length" class="load-more-tip">
  558. 已加载 {{ displayedSuccessList.length }} / {{ importResult.successList.length }} 条,滚动加载更多...
  559. </div>
  560. </el-tab-pane>
  561. <el-tab-pane label="失败列表" name="failure">
  562. <el-table
  563. :data="displayedFailureList"
  564. border
  565. stripe
  566. height="400"
  567. style="width: 100%"
  568. v-loading="failureListLoading"
  569. @scroll="handleFailureListScroll"
  570. >
  571. <el-table-column type="index" label="序号" width="60" align="center" />
  572. <el-table-column prop="rowNum" label="Excel行号" width="120" align="center" />
  573. <el-table-column prop="orderCode" label="订单号" align="center" />
  574. <el-table-column prop="errorMessage" label="错误信息" align="center" show-overflow-tooltip />
  575. </el-table>
  576. <div v-if="displayedFailureList.length < importResult.failureList.length" class="load-more-tip">
  577. 已加载 {{ displayedFailureList.length }} / {{ importResult.failureList.length }} 条,滚动加载更多...
  578. </div>
  579. </el-tab-pane>
  580. </el-tabs>
  581. <div slot="footer" class="dialog-footer">
  582. <el-button type="primary" @click="importResultDialog.open = false">关 闭</el-button>
  583. </div>
  584. </el-dialog>
  585. </div>
  586. </template>
  587. <script>
  588. import {importTemplate,batchSetErpOrder,batchCreateErpOrder,listIntegralOrder,getIntegralTemplate, getIntegralOrder, delIntegralOrder, addIntegralOrder, updateIntegralOrder, exportIntegralOrder,cancelOrder } from "@/api/his/integralOrder";
  589. import integralOrderDetails from '../../components/his/integralOrderDetails.vue';
  590. import { getToken } from "@/utils/auth";
  591. import {getCompanyList} from "@/api/company/company";
  592. import {getAllUserlist} from "@/api/company/companyUser";
  593. import {getQwUserInfo} from "@/api/qw/qwUser";
  594. import {getErpAccount } from "@/api/his/storeOrder";
  595. import {queryErpPhone, saveErpPhone} from "@/api/his/storeOrder";
  596. export default {
  597. name: "IntegralOrder",
  598. components: { integralOrderDetails },
  599. data() {
  600. return {
  601. show:{
  602. open:false,
  603. },
  604. upload: {
  605. // 是否显示弹出层
  606. open: false,
  607. // 弹出层标题
  608. title: "",
  609. // 是否禁用上传
  610. isUploading: false,
  611. // 是否更新已经存在的用户数据
  612. updateSupport: 0,
  613. // 设置上传的请求头部
  614. headers: { Authorization: "Bearer " + getToken() },
  615. // 上传的地址
  616. url: process.env.VUE_APP_BASE_API + "/his/integralOrder/importData"
  617. },
  618. // 遮罩层
  619. loading: true,
  620. actName:"10",
  621. // 导出遮罩层
  622. exportLoading: false,
  623. // 选中数组
  624. ids: [],
  625. // 非单个禁用
  626. single: true,
  627. // 非多个禁用
  628. multiple: true,
  629. // 显示搜索条件
  630. showSearch: true,
  631. // 总条数
  632. total: 0,
  633. // 积分商品订单表格数据
  634. integralOrderList: [],
  635. // 弹出层标题
  636. title: "",
  637. // 是否显示弹出层
  638. open: false,
  639. // 1:待发货;2:待收货;3:已完成字典
  640. statusOptions: [],
  641. // 查询参数
  642. queryParams: {
  643. pageNum: 1,
  644. pageSize: 10,
  645. orderCode: null,
  646. orderCodes: [], // 添加订单号数组
  647. userName: null,
  648. userPhone: null,
  649. integral: null,
  650. status: null,
  651. deliverySn: null,
  652. createTime: null,
  653. sTime:null,
  654. eTime:null,
  655. companyUserId:null,
  656. qwUserId:null,
  657. companyId:null,
  658. loginAccount: null // 添加ERP账号筛选字段
  659. },
  660. // 最大订单号数量限制
  661. maxOrderCodes: {
  662. type: Number,
  663. default: 50
  664. },
  665. // 输入框是否可见
  666. inputVisible: false,
  667. // 当前输入值
  668. currentInput: '',
  669. createTime:null,
  670. qwCompanyList:[],
  671. companyUserNameList:[],
  672. qwUserList:[],
  673. // 表单参数
  674. form: {},
  675. // 表单校验
  676. rules: {
  677. userId: [
  678. { required: true, message: "用户id不能为空", trigger: "blur" }
  679. ],
  680. status: [
  681. { required: true, message: "1:待发货;2:待收货;3:已完成不能为空", trigger: "change" }
  682. ],
  683. },
  684. dataSortOpen: false, // 数据分拣弹窗显示控制
  685. erpAccountDialog: {
  686. open: false,
  687. loading: false,
  688. submitting: false,
  689. title: "数据分拣"
  690. },
  691. erpAccountForm: {
  692. selectedAccount: null,
  693. selectedPhones: [] // 添加推送手机号字段
  694. },
  695. erpAccountList: [],
  696. orderSummary: {
  697. selectedCount: 0,
  698. totalAmount: 0,
  699. queryCount: 0
  700. },
  701. erpPhone: {
  702. open: false,
  703. title: "设置推送手机号"
  704. },
  705. phoneList: [], // 手机号列表
  706. originalPhoneList: [], // 原始手机号列表,用于取消时恢复
  707. uploadStatus: {
  708. // 是否显示弹出层
  709. open: false,
  710. // 弹出层标题
  711. title: "",
  712. // 是否禁用上传
  713. isUploading: false,
  714. // 是否更新已经存在的用户数据
  715. updateSupport: 0,
  716. // 设置上传的请求头部
  717. headers: { Authorization: "Bearer " + getToken() },
  718. // 上传的地址
  719. url: process.env.VUE_APP_BASE_API + "/his/integralOrder/importOrderStatusData"
  720. },
  721. // 导入结果对话框
  722. importResultDialog: {
  723. open: false
  724. },
  725. // 导入结果数据
  726. importResult: {
  727. successNum: 0,
  728. failureNum: 0,
  729. successList: [],
  730. failureList: []
  731. },
  732. // 导入结果标签页
  733. importResultTab: "success",
  734. // 分片加载相关
  735. displayedSuccessList: [],
  736. displayedFailureList: [],
  737. successListPageSize: 50,
  738. failureListPageSize: 50,
  739. successListCurrentPage: 1,
  740. failureListCurrentPage: 1,
  741. successListLoading: false,
  742. failureListLoading: false,
  743. };
  744. },
  745. created() {
  746. this.getList();
  747. this.getDicts("sys_integral_order_status").then(response => {
  748. this.statusOptions = response.data;
  749. });
  750. //获取企业
  751. getCompanyList().then(response => {
  752. this.qwCompanyList = response.data;
  753. });
  754. this.loadErpAccountData();
  755. },
  756. methods: {
  757. handleImportStatus() {
  758. this.uploadStatus.title = "导入";
  759. this.uploadStatus.open = true;
  760. },
  761. handleFileUploadProgressOrder(event, file, fileList) {
  762. this.uploadStatus.isUploading = true;
  763. },
  764. // 文件上传成功处理
  765. handleFileSuccessOrder(response, file, fileList) {
  766. this.uploadStatus.open = false;
  767. this.uploadStatus.isUploading = false;
  768. this.$refs.uploadStatus.clearFiles();
  769. // 处理新的返回结果格式
  770. if (response.code === 200 && response.data) {
  771. this.importResult = response.data;
  772. // 初始化显示列表
  773. this.displayedSuccessList = [];
  774. this.displayedFailureList = [];
  775. this.successListCurrentPage = 1;
  776. this.failureListCurrentPage = 1;
  777. // 加载第一页数据
  778. this.loadSuccessListPage(1);
  779. this.loadFailureListPage(1);
  780. // 显示结果对话框
  781. this.importResultDialog.open = true;
  782. this.importResultTab = this.importResult.failureNum > 0 ? "failure" : "success";
  783. } else {
  784. this.$alert(response.msg || "导入失败", "导入结果", { dangerouslyUseHTMLString: true });
  785. }
  786. this.getList();
  787. },
  788. // 加载成功列表分页数据
  789. loadSuccessListPage(page) {
  790. if (this.successListLoading) return;
  791. this.successListLoading = true;
  792. const start = (page - 1) * this.successListPageSize;
  793. const end = start + this.successListPageSize;
  794. const pageData = this.importResult.successList.slice(start, end);
  795. this.displayedSuccessList = this.displayedSuccessList.concat(pageData);
  796. this.successListCurrentPage = page;
  797. this.$nextTick(() => {
  798. this.successListLoading = false;
  799. // 绑定滚动事件
  800. if (page === 1) {
  801. this.bindScrollEvents();
  802. }
  803. });
  804. },
  805. // 加载失败列表分页数据
  806. loadFailureListPage(page) {
  807. if (this.failureListLoading) return;
  808. this.failureListLoading = true;
  809. const start = (page - 1) * this.failureListPageSize;
  810. const end = start + this.failureListPageSize;
  811. const pageData = this.importResult.failureList.slice(start, end);
  812. this.displayedFailureList = this.displayedFailureList.concat(pageData);
  813. this.failureListCurrentPage = page;
  814. this.$nextTick(() => {
  815. this.failureListLoading = false;
  816. // 绑定滚动事件
  817. if (page === 1) {
  818. this.bindScrollEvents();
  819. }
  820. });
  821. },
  822. // 绑定滚动事件
  823. bindScrollEvents() {
  824. this.$nextTick(() => {
  825. // 成功列表滚动
  826. const successTableBody = document.querySelector('.el-dialog__body .el-tabs__content .el-tab-pane:first-child .el-table__body-wrapper');
  827. if (successTableBody) {
  828. successTableBody.removeEventListener('scroll', this.handleSuccessListScroll);
  829. successTableBody.addEventListener('scroll', this.handleSuccessListScroll);
  830. }
  831. // 失败列表滚动
  832. const failureTableBody = document.querySelector('.el-dialog__body .el-tabs__content .el-tab-pane:last-child .el-table__body-wrapper');
  833. if (failureTableBody) {
  834. failureTableBody.removeEventListener('scroll', this.handleFailureListScroll);
  835. failureTableBody.addEventListener('scroll', this.handleFailureListScroll);
  836. }
  837. });
  838. },
  839. // 成功列表滚动加载
  840. handleSuccessListScroll(event) {
  841. const container = event.target;
  842. const scrollTop = container.scrollTop;
  843. const scrollHeight = container.scrollHeight;
  844. const clientHeight = container.clientHeight;
  845. // 距离底部50px时加载下一页
  846. if (scrollHeight - scrollTop - clientHeight < 50) {
  847. const totalPages = Math.ceil(this.importResult.successList.length / this.successListPageSize);
  848. if (this.successListCurrentPage < totalPages && !this.successListLoading) {
  849. this.loadSuccessListPage(this.successListCurrentPage + 1);
  850. }
  851. }
  852. },
  853. // 失败列表滚动加载
  854. handleFailureListScroll(event) {
  855. const container = event.target;
  856. const scrollTop = container.scrollTop;
  857. const scrollHeight = container.scrollHeight;
  858. const clientHeight = container.clientHeight;
  859. // 距离底部50px时加载下一页
  860. if (scrollHeight - scrollTop - clientHeight < 50) {
  861. const totalPages = Math.ceil(this.importResult.failureList.length / this.failureListPageSize);
  862. if (this.failureListCurrentPage < totalPages && !this.failureListLoading) {
  863. this.loadFailureListPage(this.failureListCurrentPage + 1);
  864. }
  865. }
  866. },
  867. importUpdateOrderTemplate(){
  868. getIntegralTemplate().then(response => {
  869. this.download(response.msg);
  870. });
  871. },
  872. //取消订单
  873. cancelOrder(orderCode){
  874. this.$confirm('确定取消此订单?', '提示', {
  875. confirmButtonText: '确定',
  876. cancelButtonText: '取消',
  877. type: 'warning'
  878. }).then(() => {
  879. console.log("orderCode",orderCode)
  880. cancelOrder(orderCode).then(()=>{
  881. this.$message({
  882. type: 'success',
  883. message: '取消成功!'
  884. });
  885. this.getList();
  886. })
  887. }).catch(() => {
  888. });
  889. },
  890. change(){
  891. if(this.createTime!=null){
  892. this.queryParams.sTime=this.createTime[0];
  893. this.queryParams.eTime=this.createTime[1];
  894. }else{
  895. this.queryParams.sTime=null;
  896. this.queryParams.eTime=null;
  897. }
  898. },
  899. handleImport() {
  900. this.upload.title = "导入";
  901. this.upload.open = true;
  902. },
  903. importTemplate() {
  904. importTemplate().then(response => {
  905. this.download(response.msg);
  906. });
  907. },
  908. // 文件上传中处理
  909. handleFileUploadProgress(event, file, fileList) {
  910. this.upload.isUploading = true;
  911. },
  912. // 文件上传成功处理
  913. handleFileSuccess(response, file, fileList) {
  914. this.upload.open = false;
  915. this.upload.isUploading = false;
  916. this.$refs.upload.clearFiles();
  917. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  918. this.getList();
  919. },
  920. // 提交上传文件
  921. submitFileForm() {
  922. this.$refs.upload.submit();
  923. },
  924. handledetails(row){
  925. this.show.open=true;
  926. setTimeout(() => {
  927. this.$refs.Details.getDetails(row.orderId);
  928. }, 1);
  929. },
  930. /** 查询积分商品订单列表 */
  931. /** 查询积分商品订单列表 */
  932. getList() {
  933. this.loading = true;
  934. // 直接传递订单编号数组给后端
  935. listIntegralOrder(this.queryParams).then(response => {
  936. // 解析itemJson字段,提取goodsName和图片
  937. const processedData = response.rows.map(item => {
  938. let goodsName = '';
  939. let goodsImage = '';
  940. let num = '';
  941. try {
  942. if (item.itemJson) {
  943. const itemData = JSON.parse(item.itemJson);
  944. // 如果itemJson是数组格式,遍历数组并用换行分隔每个商品
  945. if (Array.isArray(itemData) && itemData.length > 0) {
  946. // 提取所有商品的信息,每个商品一行
  947. const goodsInfoList = itemData
  948. .filter(goods => goods.goodsName)
  949. .map(goods => {
  950. const name = goods.goodsName || '';
  951. const itemNum = goods.num || 1; // 如果没有数量,默认1
  952. return `${name},数量:${itemNum}个`;
  953. });
  954. // 如果有多个商品,用换行符分隔
  955. if (goodsInfoList.length > 0) {
  956. goodsName = goodsInfoList.join('\n');
  957. } else if (itemData[0].goodsName) {
  958. // 如果没有商品名称但有第一个商品对象,使用第一个
  959. const firstItem = itemData[0];
  960. goodsName = `${firstItem.goodsName || ''},数量:${firstItem.num || 1}个`;
  961. }
  962. // 提取第一个商品的图片
  963. const firstItem = itemData[0];
  964. if (firstItem.imgUrl) {
  965. goodsImage = firstItem.imgUrl;
  966. } else if (firstItem.images && firstItem.images.split(',').length > 0) {
  967. goodsImage = firstItem.images.split(',')[0];
  968. }
  969. }
  970. // 如果itemJson是对象格式,直接取goodsName和图片
  971. else if (itemData.goodsName) {
  972. goodsName = `${itemData.goodsName},数量:${itemData.num || 1}个`;
  973. // 提取图片,优先使用imgUrl,如果没有则使用images的第一张
  974. if (itemData.imgUrl) {
  975. goodsImage = itemData.imgUrl;
  976. } else if (itemData.images && itemData.images.split(',').length > 0) {
  977. goodsImage = itemData.images.split(',')[0];
  978. }
  979. }
  980. }
  981. } catch (error) {
  982. console.error('解析itemJson失败:', error);
  983. goodsName = '';
  984. goodsImage = '';
  985. num = '';
  986. }
  987. return {
  988. ...item,
  989. goodsName: goodsName,
  990. goodsImage: goodsImage,
  991. num: num
  992. };
  993. });
  994. this.integralOrderList = processedData;
  995. this.total = response.total;
  996. this.loading = false;
  997. }).catch(error => {
  998. console.error('查询订单列表失败:', error);
  999. this.loading = false;
  1000. this.$message.error('查询订单列表失败');
  1001. });
  1002. },
  1003. /** 查询积分商品订单列表 */
  1004. //原代码 先留着
  1005. getList0() {
  1006. this.loading = true;
  1007. // 直接传递订单编号数组给后端
  1008. listIntegralOrder(this.queryParams).then(response => {
  1009. // 解析itemJson字段,提取goodsName和图片
  1010. const processedData = response.rows.map(item => {
  1011. let goodsName = '';
  1012. let goodsImage = '';
  1013. let num = '';
  1014. try {
  1015. if (item.itemJson) {
  1016. const itemData = JSON.parse(item.itemJson);
  1017. // 如果itemJson是数组格式,取第一个商品的名称和图片
  1018. if (Array.isArray(itemData) && itemData.length > 0) {
  1019. goodsName = itemData[0].goodsName || '';
  1020. // 提取图片,优先使用imgUrl,如果没有则使用images的第一张
  1021. if (itemData[0].imgUrl) {
  1022. goodsImage = itemData[0].imgUrl;
  1023. } else if (itemData[0].images && itemData[0].images.split(',').length > 0) {
  1024. goodsImage = itemData[0].images.split(',')[0];
  1025. }
  1026. }
  1027. // 如果itemJson是对象格式,直接取goodsName和图片
  1028. else if (itemData.goodsName) {
  1029. goodsName = itemData.goodsName;
  1030. // 提取图片,优先使用imgUrl,如果没有则使用images的第一张
  1031. if (itemData.imgUrl) {
  1032. goodsImage = itemData.imgUrl;
  1033. } else if (itemData.images && itemData.images.split(',').length > 0) {
  1034. goodsImage = itemData.images.split(',')[0];
  1035. }
  1036. }
  1037. }
  1038. } catch (error) {
  1039. console.error('解析itemJson失败:', error);
  1040. goodsName = '';
  1041. goodsImage = '';
  1042. num ='';
  1043. }
  1044. return {
  1045. ...item,
  1046. goodsName: goodsName,
  1047. goodsImage: goodsImage,
  1048. num: num
  1049. };
  1050. });
  1051. this.integralOrderList = processedData;
  1052. this.total = response.total;
  1053. this.loading = false;
  1054. }).catch(error => {
  1055. console.error('查询订单列表失败:', error);
  1056. this.loading = false;
  1057. this.$message.error('查询订单列表失败');
  1058. });
  1059. },
  1060. // 取消按钮
  1061. cancel() {
  1062. this.open = false;
  1063. this.reset();
  1064. },
  1065. // 表单重置
  1066. reset() {
  1067. this.form = {
  1068. orderId: null,
  1069. orderCode: null,
  1070. userId: null,
  1071. userName: null,
  1072. userPhone: null,
  1073. userAddress: null,
  1074. itemJson: null,
  1075. integral: null,
  1076. status: null,
  1077. deliveryCode: null,
  1078. deliveryName: null,
  1079. deliverySn: null,
  1080. deliveryTime: null,
  1081. createTime: null,
  1082. remark: null,
  1083. sTime:null,
  1084. eTime:null,
  1085. };
  1086. this.resetForm("form");
  1087. },
  1088. /** 搜索按钮操作 */
  1089. handleQuery() {
  1090. this.queryParams.pageNum = 1;
  1091. this.getList();
  1092. },
  1093. /** 重置按钮操作 */
  1094. resetQuery() {
  1095. this.resetForm("queryForm");
  1096. this.createTime=null;
  1097. this.queryParams.sTime=null;
  1098. this.queryParams.eTime=null;
  1099. this.queryParams.qwUserId=null;
  1100. this.queryParams.companyId=null;
  1101. this.queryParams.companyUserId=null;
  1102. // 清除订单号标签
  1103. this.queryParams.orderCodes = [];
  1104. this.currentInput = '';
  1105. this.inputVisible = false;
  1106. this.handleQuery();
  1107. },
  1108. // 多选框选中数据
  1109. handleSelectionChange(selection) {
  1110. this.ids = selection.map(item => item.orderId)
  1111. this.single = selection.length!==1
  1112. this.multiple = !selection.length
  1113. },
  1114. /** 新增按钮操作 */
  1115. handleAdd() {
  1116. this.reset();
  1117. this.open = true;
  1118. this.title = "添加积分商品订单";
  1119. },
  1120. /** 修改按钮操作 */
  1121. handleUpdate(row) {
  1122. this.reset();
  1123. const orderId = row.orderId || this.ids
  1124. getIntegralOrder(orderId).then(response => {
  1125. this.form = response.data;
  1126. this.open = true;
  1127. this.title = "修改积分商品订单";
  1128. });
  1129. },
  1130. /** 提交按钮 */
  1131. submitForm() {
  1132. this.$refs["form"].validate(valid => {
  1133. if (valid) {
  1134. if (this.form.orderId != null) {
  1135. updateIntegralOrder(this.form).then(response => {
  1136. this.msgSuccess("修改成功");
  1137. this.open = false;
  1138. this.getList();
  1139. });
  1140. } else {
  1141. addIntegralOrder(this.form).then(response => {
  1142. this.msgSuccess("新增成功");
  1143. this.open = false;
  1144. this.getList();
  1145. });
  1146. }
  1147. }
  1148. });
  1149. },
  1150. handleClickX(tab, event) {
  1151. if(tab.name=="10"){
  1152. this.queryParams.status=null;
  1153. }else{
  1154. this.queryParams.status=tab.name;
  1155. }
  1156. this.handleQuery();
  1157. },
  1158. /** 删除按钮操作 */
  1159. handleDelete(row) {
  1160. const orderIds = row.orderId || this.ids;
  1161. this.$confirm('是否确认删除积分商品订单编号为"' + orderIds + '"的数据项?', "警告", {
  1162. confirmButtonText: "确定",
  1163. cancelButtonText: "取消",
  1164. type: "warning"
  1165. }).then(function() {
  1166. return delIntegralOrder(orderIds);
  1167. }).then(() => {
  1168. this.getList();
  1169. this.msgSuccess("删除成功");
  1170. }).catch(() => {});
  1171. },
  1172. /** 导出按钮操作 */
  1173. handleExport() {
  1174. const queryParams = this.queryParams;
  1175. this.$confirm('是否确认导出所有积分商品订单数据项?', "警告", {
  1176. confirmButtonText: "确定",
  1177. cancelButtonText: "取消",
  1178. type: "warning"
  1179. }).then(() => {
  1180. this.exportLoading = true;
  1181. return exportIntegralOrder(queryParams);
  1182. }).then(response => {
  1183. this.download(response.msg);
  1184. this.exportLoading = false;
  1185. }).catch(() => {});
  1186. },
  1187. //选择企业后触发
  1188. getAllUserlist(companyId){
  1189. if(companyId){
  1190. getAllUserlist({companyId}).then(response => {
  1191. this.companyUserNameList=response.data;
  1192. });
  1193. //企业微信
  1194. getQwUserInfo({companyId}).then(response => {
  1195. this.qwUserList=response.data;
  1196. })
  1197. }
  1198. },
  1199. // 数据分拣按钮点击事件
  1200. handleDataSort() {
  1201. this.erpAccountDialog.open = true;
  1202. this.erpAccountDialog.title = "数据分拣";
  1203. this.getErpPhoneList(); // 加载手机号列表
  1204. this.updateOrderSummary();
  1205. },
  1206. // 加载ERP账户数据
  1207. async loadErpAccountData() {
  1208. try {
  1209. const response = await getErpAccount();
  1210. this.erpAccountList = response.data;
  1211. } catch (error) {
  1212. console.error('加载ERP账户失败:', error);
  1213. }
  1214. },
  1215. // 更新订单统计
  1216. updateOrderSummary() {
  1217. // 如果没有选择任何数据,则使用查询出来的所有数据
  1218. if (this.ids.length === 0) {
  1219. this.orderSummary.selectedCount = this.total;
  1220. this.orderSummary.queryCount = this.total;
  1221. } else {
  1222. // 如果选择了数据,则使用选中的数据
  1223. this.orderSummary.selectedCount = this.ids.length;
  1224. this.orderSummary.queryCount = this.total;
  1225. }
  1226. // 计算总金额(这里需要根据实际数据结构调整)
  1227. this.calculateTotalAmount();
  1228. },
  1229. // 计算总金额
  1230. calculateTotalAmount() {
  1231. let totalAmount = 0;
  1232. if (this.ids.length === 0) {
  1233. // 使用所有查询数据计算金额
  1234. this.integralOrderList.forEach(order => {
  1235. totalAmount += parseFloat(order.payMoney || 0);
  1236. });
  1237. } else {
  1238. // 使用选中的数据计算金额
  1239. const selectedOrders = this.integralOrderList.filter(order =>
  1240. this.ids.includes(order.orderId)
  1241. );
  1242. selectedOrders.forEach(order => {
  1243. totalAmount += parseFloat(order.payMoney || 0);
  1244. });
  1245. }
  1246. this.orderSummary.totalAmount = totalAmount.toFixed(2);
  1247. },
  1248. // 取消ERP账户对话框
  1249. cancelErpAccountDialog() {
  1250. this.erpAccountDialog.open = false;
  1251. this.erpAccountForm.selectedAccount = null;
  1252. },
  1253. // 确认创建ERP订单
  1254. async confirmCreateErpOrder() {
  1255. // 收集选中的orderId
  1256. let selectedOrderIds = [];
  1257. if (this.ids.length === 0) {
  1258. // 如果没有选择任何数据,使用查询出来的所有数据的orderId
  1259. selectedOrderIds = this.integralOrderList.map(order => order.orderId);
  1260. } else {
  1261. // 如果选择了数据,使用选中的orderId
  1262. selectedOrderIds = this.ids;
  1263. }
  1264. // 收集ERP账户和手机号
  1265. const selectedErpAccount = this.erpAccountForm.selectedAccount;
  1266. const selectedPhones = this.erpAccountForm.selectedPhones;
  1267. // 准备请求参数
  1268. const params = {
  1269. orderIds: selectedOrderIds,
  1270. loginAccount: selectedErpAccount,
  1271. erpPhones: selectedPhones // 添加手机号参数
  1272. };
  1273. try {
  1274. this.erpAccountDialog.submitting = true;
  1275. // 根据弹窗标题判断是数据分拣还是创建ERP
  1276. if (this.erpAccountDialog.title === "数据分拣") {
  1277. // 调用数据分拣接口
  1278. const response = await batchSetErpOrder(params);
  1279. this.$message.success('数据分拣成功');
  1280. } else if (this.erpAccountDialog.title === "创建ERP") {
  1281. // 调用创建ERP接口
  1282. const response = await batchCreateErpOrder(params);
  1283. // console.log("参数:",params)
  1284. this.$message.success('创建ERP成功');
  1285. }
  1286. // 关闭弹窗
  1287. this.cancelErpAccountDialog();
  1288. // 刷新列表
  1289. this.getList();
  1290. } catch (error) {
  1291. console.error('操作失败:', error);
  1292. this.$message.error('操作失败');
  1293. } finally {
  1294. this.erpAccountDialog.submitting = false;
  1295. }
  1296. },
  1297. handleCreateErp() {
  1298. this.erpAccountDialog.open = true;
  1299. this.erpAccountDialog.title = "创建ERP";
  1300. this.getErpPhoneList(); // 加载手机号列表
  1301. this.updateOrderSummary();
  1302. },
  1303. // 获取ERP手机号列表
  1304. getErpPhoneList() {
  1305. queryErpPhone().then(response => {
  1306. if (response.data && response.data != null && response.data.length > 0) {
  1307. const phones = response.data.filter(phone => phone.trim());
  1308. this.phoneList = phones.map(phone => ({
  1309. phone: phone.trim(),
  1310. editing: false,
  1311. originalPhone: phone.trim()
  1312. }));
  1313. } else {
  1314. this.phoneList = [];
  1315. }
  1316. });
  1317. },
  1318. // 取消ERP账户对话框
  1319. cancelErpAccountDialog() {
  1320. this.erpAccountDialog.open = false;
  1321. this.erpAccountForm.selectedAccount = null;
  1322. this.erpAccountForm.selectedPhones = []; // 清空手机号选择
  1323. },
  1324. // 推送手机号码管理
  1325. handleErpPhone() {
  1326. this.getErpPhoneList();
  1327. this.erpPhone.open = true;
  1328. },
  1329. // 新增手机号
  1330. handleAddPhone() {
  1331. this.phoneList.push({
  1332. phone: '',
  1333. editing: true,
  1334. originalPhone: '',
  1335. isNew: true
  1336. });
  1337. },
  1338. // 编辑手机号
  1339. handleEditPhone(index) {
  1340. this.$set(this.phoneList[index], 'editing', true);
  1341. this.$set(this.phoneList[index], 'originalPhone', this.phoneList[index].phone);
  1342. },
  1343. // 保存手机号
  1344. handleSavePhone(index) {
  1345. const phone = this.phoneList[index].phone.trim();
  1346. if (!phone) {
  1347. this.$message.error('手机号不能为空');
  1348. return;
  1349. }
  1350. if (!this.validatePhoneFormat(phone)) {
  1351. this.$message.error('请输入正确的手机号格式');
  1352. return;
  1353. }
  1354. // 检查是否重复
  1355. const duplicateIndex = this.phoneList.findIndex((item, idx) =>
  1356. idx !== index && item.phone === phone
  1357. );
  1358. if (duplicateIndex !== -1) {
  1359. this.$message.error('手机号已存在');
  1360. return;
  1361. }
  1362. this.$set(this.phoneList[index], 'editing', false);
  1363. this.$set(this.phoneList[index], 'isNew', false);
  1364. },
  1365. // 取消编辑
  1366. handleCancelEdit(index) {
  1367. if (this.phoneList[index].isNew) {
  1368. // 如果是新增的,直接删除
  1369. this.phoneList.splice(index, 1);
  1370. } else {
  1371. // 如果是编辑的,恢复原值
  1372. this.$set(this.phoneList[index], 'phone', this.phoneList[index].originalPhone);
  1373. this.$set(this.phoneList[index], 'editing', false);
  1374. }
  1375. },
  1376. // 删除手机号
  1377. handleDeletePhone(index) {
  1378. this.$confirm('确认删除该手机号?', '提示', {
  1379. confirmButtonText: '确定',
  1380. cancelButtonText: '取消',
  1381. type: 'warning'
  1382. }).then(() => {
  1383. this.phoneList.splice(index, 1);
  1384. this.$message.success('删除成功');
  1385. });
  1386. },
  1387. // 验证手机号格式
  1388. validatePhoneFormat(phone) {
  1389. const phoneRegex = /^1[3-9]\d{9}$/;
  1390. return phoneRegex.test(phone);
  1391. },
  1392. // 验证手机号
  1393. validatePhone(row) {
  1394. if (row.phone && !this.validatePhoneFormat(row.phone)) {
  1395. this.$message.error('请输入正确的手机号格式');
  1396. }
  1397. },
  1398. // 保存手机号列表
  1399. handleSavePhoneList() {
  1400. // 检查是否有正在编辑的项
  1401. const editingItem = this.phoneList.find(item => item.editing);
  1402. if (editingItem) {
  1403. this.$message.error('请先保存正在编辑的手机号');
  1404. return;
  1405. }
  1406. // 检查是否有空的手机号
  1407. const emptyPhone = this.phoneList.find(item => !item.phone.trim());
  1408. if (emptyPhone) {
  1409. this.$message.error('存在空的手机号,请删除或填写完整');
  1410. return;
  1411. }
  1412. // 构造手机号列表
  1413. const phoneList = this.phoneList.map(item => item.phone);
  1414. // 调用保存接口
  1415. saveErpPhone(phoneList).then(response => {
  1416. if (response.code === 200) {
  1417. this.$message.success('保存成功');
  1418. this.erpPhone.open = false;
  1419. } else {
  1420. this.$message.error(response.msg || '保存失败');
  1421. }
  1422. }).catch(() => {
  1423. this.$message.error('保存失败');
  1424. });
  1425. },
  1426. // 取消手机号对话框
  1427. handleCancelPhoneDialog() {
  1428. this.erpPhone.open = false;
  1429. this.getErpPhoneList(); // 重新加载原始数据
  1430. },
  1431. submitOrderStatusFileForm(){
  1432. this.$refs.uploadStatus.submit();
  1433. },
  1434. // 处理键盘按下事件
  1435. handleKeyDown(event) {
  1436. const { key, target } = event
  1437. // 处理退格键删除标签
  1438. if (key === 'Backspace' && !target.value && this.queryParams.orderCodes.length > 0) {
  1439. event.preventDefault()
  1440. this.removeOrderCode(this.queryParams.orderCodes.length - 1)
  1441. }
  1442. // 处理分隔符
  1443. if ([',', ',', ' ', 'Enter'].includes(key)) {
  1444. event.preventDefault()
  1445. this.handleInputConfirm()
  1446. }
  1447. },
  1448. // 处理键盘抬起事件(实时分割输入)
  1449. handleKeyUp(event) {
  1450. const value = event.target.value
  1451. // 检查是否包含分隔符
  1452. if (/[,,\s]/.test(value)) {
  1453. this.handleInputConfirm()
  1454. }
  1455. },
  1456. // 确认输入
  1457. handleInputConfirm() {
  1458. const inputValue = this.currentInput.trim()
  1459. if (inputValue) {
  1460. // 分割多个订单号
  1461. const codes = inputValue.split(/[,,\s]+/).filter(code => code.trim())
  1462. codes.forEach(code => {
  1463. this.addOrderCode(code.trim())
  1464. })
  1465. }
  1466. this.currentInput = ''
  1467. },
  1468. // 添加订单号
  1469. addOrderCode(code) {
  1470. if (!code) return
  1471. // 检查数量限制
  1472. if (this.maxOrderCodes > 0 && this.queryParams.orderCodes.length >= this.maxOrderCodes) {
  1473. this.$message.warning(`最多只能添加 ${this.maxOrderCodes} 个订单号`)
  1474. return
  1475. }
  1476. // 检查重复
  1477. if (this.queryParams.orderCodes.includes(code)) {
  1478. this.$message.warning(`订单号 "${code}" 已存在`)
  1479. return
  1480. }
  1481. // 添加到列表
  1482. this.queryParams.orderCodes.push(code)
  1483. },
  1484. // 删除订单号
  1485. removeOrderCode(index) {
  1486. this.queryParams.orderCodes.splice(index, 1)
  1487. },
  1488. // 显示输入框
  1489. showInput() {
  1490. this.inputVisible = true
  1491. this.$nextTick(() => {
  1492. this.$refs.tagInput.focus()
  1493. })
  1494. },
  1495. // 聚焦输入框
  1496. focusInput() {
  1497. if (!this.inputVisible) {
  1498. this.showInput()
  1499. }
  1500. },
  1501. }
  1502. };
  1503. </script>
  1504. <style scoped>
  1505. .tag-input-container {
  1506. min-width: 445px;
  1507. }
  1508. .tags-wrapper {
  1509. min-height: 32px;
  1510. padding: 4px 8px;
  1511. border: 1px solid #dcdfe6;
  1512. border-radius: 4px;
  1513. cursor: text;
  1514. display: flex;
  1515. flex-wrap: wrap;
  1516. align-items: center;
  1517. gap: 4px;
  1518. transition: border-color 0.2s;
  1519. }
  1520. .tags-wrapper:hover {
  1521. border-color: #c0c4cc;
  1522. }
  1523. .tags-wrapper:focus-within {
  1524. border-color: #409eff;
  1525. box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
  1526. }
  1527. .order-tag {
  1528. margin: 2px;
  1529. flex-shrink: 0;
  1530. }
  1531. .tag-error {
  1532. background-color: #fef0f0;
  1533. border-color: #fbc4c4;
  1534. color: #f56c6c;
  1535. }
  1536. .tag-input {
  1537. border: none;
  1538. outline: none;
  1539. flex: 1;
  1540. min-width: 120px;
  1541. }
  1542. .tag-input >>> .el-input__inner {
  1543. border: none;
  1544. padding: 0;
  1545. height: 24px;
  1546. line-height: 24px;
  1547. }
  1548. .button-new-tag {
  1549. height: 24px;
  1550. line-height: 22px;
  1551. padding: 0 8px;
  1552. margin: 2px;
  1553. }
  1554. .input-tips {
  1555. margin-top: 4px;
  1556. font-size: 12px;
  1557. color: #909399;
  1558. }
  1559. .tip-text {
  1560. display: flex;
  1561. align-items: center;
  1562. gap: 8px;
  1563. }
  1564. /* 导入结果样式 */
  1565. .import-result-summary {
  1566. margin-bottom: 20px;
  1567. padding: 20px;
  1568. background-color: #f5f7fa;
  1569. border-radius: 4px;
  1570. }
  1571. .summary-item {
  1572. text-align: center;
  1573. padding: 15px;
  1574. border-radius: 4px;
  1575. }
  1576. .summary-item.success {
  1577. background-color: #f0f9ff;
  1578. border: 1px solid #b3d8ff;
  1579. }
  1580. .summary-item.failure {
  1581. background-color: #fef0f0;
  1582. border: 1px solid #fbc4c4;
  1583. }
  1584. .summary-item.total {
  1585. background-color: #f4f4f5;
  1586. border: 1px solid #d3d4d6;
  1587. }
  1588. .summary-label {
  1589. font-size: 14px;
  1590. color: #606266;
  1591. margin-bottom: 8px;
  1592. }
  1593. .summary-value {
  1594. font-size: 24px;
  1595. font-weight: bold;
  1596. }
  1597. .summary-item.success .summary-value {
  1598. color: #67c23a;
  1599. }
  1600. .summary-item.failure .summary-value {
  1601. color: #f56c6c;
  1602. }
  1603. .summary-item.total .summary-value {
  1604. color: #909399;
  1605. }
  1606. .load-more-tip {
  1607. text-align: center;
  1608. padding: 10px;
  1609. color: #909399;
  1610. font-size: 12px;
  1611. }
  1612. </style>