index.vue 56 KB

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