index.vue 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084
  1. <template>
  2. <el-card shadow="always" :body-style="{ padding: '10px' }">
  3. <div class="app-container">
  4. <el-dialog
  5. :title="upload.title"
  6. :visible.sync="upload.open"
  7. width="400px"
  8. append-to-body
  9. >
  10. <el-upload
  11. ref="upload"
  12. :limit="1"
  13. accept=".xlsx, .xls"
  14. :headers="upload.headers"
  15. :action="
  16. upload.url +
  17. '?updateSupport=' +
  18. upload.updateSupport +
  19. '&tableName=' +
  20. tableName +
  21. '&sqlKey=' +
  22. tableKey
  23. "
  24. v-loading="upload.isUploading"
  25. :disabled="upload.isUploading"
  26. :on-progress="handleFileUploadProgress"
  27. :on-success="handleFileSuccess"
  28. :auto-upload="false"
  29. :onChange="handleChange"
  30. drag
  31. >
  32. <i class="el-icon-upload"></i>
  33. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  34. <div class="el-upload__tip text-center" slot="tip">
  35. <!-- <div class="el-upload__tip" slot="tip">-->
  36. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  37. <!-- 是否更新已经存在的用户数据-->
  38. <!-- </div>-->
  39. <span>仅允许导入xls、xlsx格式文件。</span>
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. style="font-size: 12px; vertical-align: baseline"
  44. @click="importTemplate"
  45. >下载模板
  46. </el-link>
  47. </div>
  48. </el-upload>
  49. <div slot="footer" class="dialog-footer">
  50. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  51. <el-button @click="upload.open = false">取 消</el-button>
  52. </div>
  53. </el-dialog>
  54. <Queryfrom
  55. :form-vals="templateInfo.where"
  56. :statisticList="statisticList"
  57. :showCount="showCount"
  58. :showSearch="showSearch"
  59. @getList="getList"
  60. ref="mychild"
  61. />
  62. <el-row :gutter="10" class="mb8">
  63. <el-col :span="1.5">
  64. <el-button
  65. type="primary"
  66. plain
  67. icon="el-icon-plus"
  68. size="mini"
  69. @click="addHandler"
  70. >新增
  71. </el-button>
  72. </el-col>
  73. <!-- <el-col :span="1.5" v-if="false">
  74. <el-button
  75. type="success"
  76. plain
  77. icon="el-icon-edit"
  78. size="mini"
  79. :disabled="single"
  80. @click="handleUpdate"
  81. >修改
  82. </el-button>
  83. </el-col> -->
  84. <el-col :span="1.5">
  85. <el-button
  86. type="danger"
  87. plain
  88. icon="el-icon-delete"
  89. size="mini"
  90. :disabled="multiple"
  91. @click="myDeleteHandler"
  92. >删除
  93. </el-button>
  94. </el-col>
  95. <!-- <el-col :span="1.5">
  96. <el-button
  97. plain
  98. icon="el-icon-upload2"
  99. size="mini"
  100. @click="upload.open = true"
  101. >导入
  102. </el-button>
  103. </el-col>
  104. <el-col :span="1.5">
  105. <el-button
  106. type="warning"
  107. plain
  108. icon="el-icon-download"
  109. size="mini"
  110. @click="handleExport"
  111. >导出
  112. </el-button>
  113. </el-col>
  114. <right-toolbar
  115. style="float: right"
  116. :showCount.sync="showCount"
  117. :showSearch.sync="showSearch"
  118. :counts="true"
  119. @queryTable="pageList"
  120. ></right-toolbar> -->
  121. </el-row>
  122. <el-table
  123. v-loading="loading"
  124. :data="tableList"
  125. @selection-change="handleSelectionChange"
  126. ref="tableRef"
  127. :cell-style="cellStyle"
  128. :reserve-selection="true"
  129. row-key="saleOrderId"
  130. >
  131. <el-table-column
  132. type="selection"
  133. width="55"
  134. reserve-selection
  135. align="center"
  136. >
  137. </el-table-column>
  138. <!-- <el-table-column type="selection" width="55" /> -->
  139. <el-table-column prop="saleNo" label="合同号" />
  140. <el-table-column prop="saleDate" label="日期" />
  141. <el-table-column prop="customName" label="客户名称" />
  142. <el-table-column prop="deliveryDate" label="交货日期" />
  143. <el-table-column prop="saleLeadTime" label="交货天数" />
  144. <el-table-column prop="saleAmountInWords" label="合计金额(大写)" />
  145. <el-table-column prop="status" label="状态">
  146. <template slot-scope="scope">
  147. <el-tag :type="scope.row.listClass">{{
  148. getDictLabel(scope.row.status, "sales_order_status")
  149. }}</el-tag>
  150. </template>
  151. </el-table-column>
  152. <el-table-column prop="salesman" label="销售员" />
  153. <el-table-column prop="remark" label="备注" />
  154. <el-table-column label="操作">
  155. <template slot-scope="scope">
  156. <el-dropdown>
  157. <el-button type="warning" plain size="small">
  158. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  159. </el-button>
  160. <el-dropdown-menu slot="dropdown">
  161. <el-dropdown-item v-show="scope.row.status == 1">
  162. <el-button
  163. size="mini"
  164. type="text"
  165. icon="el-icon-edit"
  166. @click="handleUpdate(scope.row)"
  167. >修改
  168. </el-button>
  169. </el-dropdown-item>
  170. <el-dropdown-item>
  171. <el-button
  172. size="mini"
  173. type="text"
  174. icon="el-icon-tickets"
  175. @click="handlePrint(scope.row)"
  176. >详情
  177. </el-button>
  178. </el-dropdown-item>
  179. <el-dropdown-item v-show="scope.row.status == 1">
  180. <el-button
  181. size="mini"
  182. type="text"
  183. icon="el-icon-folder-checked"
  184. @click="handleSubmit(scope.row)"
  185. >提交
  186. </el-button>
  187. </el-dropdown-item>
  188. <el-dropdown-item v-show="scope.row.status == 5">
  189. <el-button
  190. size="mini"
  191. type="text"
  192. icon="el-icon-folder-delete"
  193. @click="handleSubmitCancel(scope.row)"
  194. >撤销
  195. </el-button>
  196. </el-dropdown-item>
  197. <el-dropdown-item v-show="scope.row.status != 1">
  198. <el-button
  199. size="mini"
  200. type="text"
  201. icon="el-icon-folder-delete"
  202. @click="handleOutDetail(scope.row)"
  203. >出库明细
  204. </el-button>
  205. </el-dropdown-item>
  206. <el-dropdown-item
  207. v-show="
  208. scope.row.status == 1 ||
  209. scope.row.status == 2 ||
  210. scope.row.status == 8
  211. "
  212. >
  213. <el-button
  214. size="mini"
  215. type="text"
  216. icon="el-icon-folder-delete"
  217. @click="myPrintOutBoundHandler(scope.row)"
  218. >打印出库单
  219. </el-button>
  220. </el-dropdown-item>
  221. <el-dropdown-item v-show="scope.row.status == 1">
  222. <el-button
  223. size="mini"
  224. type="text"
  225. icon="el-icon-delete"
  226. @click="handleDelete(scope.row)"
  227. >删除
  228. </el-button>
  229. </el-dropdown-item>
  230. </el-dropdown-menu>
  231. </el-dropdown>
  232. </template>
  233. </el-table-column>
  234. </el-table>
  235. <pagination
  236. v-show="total > 0"
  237. :total="total"
  238. :page.sync="queryParams.pageNum"
  239. :limit.sync="queryParams.pageSize"
  240. @pagination="pageList"
  241. />
  242. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  243. <el-dialog
  244. :title="title"
  245. width="1100px"
  246. :visible.sync="open"
  247. append-to-body
  248. >
  249. <el-row :gutter="20">
  250. <el-form
  251. :model="formData"
  252. ref="formDataRef"
  253. :rules="rules"
  254. label-width="100px"
  255. :inline="true"
  256. size="normal"
  257. >
  258. <el-col :span="12">
  259. <el-form-item prop="saleNo" label="合同号:">
  260. <!-- <el-input size="small" v-model="formData.saleNo"></el-input> -->
  261. {{ formData.saleNo }}
  262. </el-form-item>
  263. </el-col>
  264. <!-- <el-col :span="12">
  265. <el-form-item prop="lotNumber" label="批号:">
  266. <el-input size="small" v-model="formData.lotNumber"></el-input>
  267. </el-form-item>
  268. </el-col> -->
  269. <el-col :span="12">
  270. <el-form-item prop="saleDate" label="日期:">
  271. <!-- <el-date-picker
  272. size="small"
  273. v-model="formData.saleDate"
  274. value-format="yyyy-MM-dd"
  275. format="yyyy-MM-dd"
  276. type="date"
  277. placeholder="选择日期"
  278. >
  279. </el-date-picker> -->
  280. {{ formData.saleDate }}
  281. </el-form-item>
  282. </el-col>
  283. <el-col :span="12">
  284. <el-form-item prop="saleCustomNo" label="客户名称:">
  285. <el-select
  286. size="small"
  287. v-model="formData.saleCustomNo"
  288. placeholder="请选择客户"
  289. clearable
  290. filterable
  291. @change="customChangeHandler"
  292. >
  293. <el-option
  294. v-for="item in customerOptions"
  295. :key="item.customNo"
  296. :label="item.customName"
  297. :value="item.customNo"
  298. >
  299. </el-option>
  300. </el-select>
  301. </el-form-item>
  302. </el-col>
  303. <el-col :span="12">
  304. <el-form-item v-if="isLeader" label="业务员:">
  305. <el-select
  306. size="small"
  307. v-model="formData.salesman"
  308. placeholder="请选择业务员"
  309. clearable
  310. filterable
  311. @change="salemanChange"
  312. >
  313. <el-option
  314. v-for="item in salesmanList"
  315. :key="item.value"
  316. :label="item.label"
  317. :value="item.value"
  318. >
  319. </el-option>
  320. </el-select>
  321. </el-form-item>
  322. <el-form-item v-else label="业务员:">
  323. <!-- <el-input
  324. v-model="formData.salesman"
  325. size="small"
  326. clearable
  327. ></el-input> -->
  328. {{ nickName }}
  329. </el-form-item>
  330. </el-col>
  331. <el-col :span="12">
  332. <el-form-item label="联系人:" size="normal">
  333. {{ formData.contactPerson }}
  334. </el-form-item>
  335. <el-form-item label="客户地址:" size="normal">
  336. {{ formData.customAddress }}
  337. </el-form-item>
  338. <el-form-item label="客户国别:" size="normal">
  339. {{ formData.customCountryType }}
  340. </el-form-item>
  341. </el-col>
  342. <el-col :span="12">
  343. <el-form-item label-width="120px" label="合计金额(大写):">
  344. <!-- <el-input
  345. v-model="formData.saleAmountInWords"
  346. size="small"
  347. clearable
  348. ></el-input> -->
  349. {{ formData.saleAmountInWords }}
  350. </el-form-item>
  351. </el-col>
  352. <!-- <el-col :span="12">
  353. <el-form-item label="付款方式:">
  354. <el-select
  355. v-model="formData.salePayType"
  356. size="small"
  357. clearable
  358. filterable
  359. >
  360. <el-option
  361. v-for="item in dict.type.retail_order_pay_method"
  362. :key="item.value"
  363. :label="item.label"
  364. :value="item.value"
  365. ></el-option>
  366. </el-select>
  367. 零售单
  368. </el-form-item>
  369. </el-col> -->
  370. <!-- <el-col :span="12">
  371. <el-form-item
  372. label-width="120px"
  373. prop="saleOrderEstimatedTime"
  374. label="预计下单时间:"
  375. >
  376. {{ formData.saleOrderEstimatedTime }}
  377. </el-form-item>
  378. </el-col> -->
  379. <!-- <el-col :span="12">
  380. <el-form-item label="交货日期:" size="normal" prop="deliveryDate">
  381. {{ formData.deliveryDate }}
  382. </el-form-item>
  383. </el-col> -->
  384. <!-- <el-col :span="12">
  385. <el-form-item label="交货天数:" size="normal" prop="saleLeadTime">
  386. {{ formData.saleLeadTime }}
  387. </el-form-item>
  388. </el-col> -->
  389. <el-col :span="24">
  390. <el-divider>货品明细</el-divider>
  391. </el-col>
  392. <el-table
  393. :data="productionTableData"
  394. border
  395. show-summary
  396. :summary-method="getSummaries"
  397. sum-text="小计"
  398. style="width: 100%"
  399. >
  400. <el-table-column prop="productName" label="品名" width="180">
  401. <template slot-scope="scope">
  402. <!-- <el-input
  403. v-model="scope.row.productName"
  404. size="small"
  405. clearable
  406. ></el-input> -->
  407. <el-form-item
  408. :prop="'productNo-' + scope.$index"
  409. :name="'productNo-' + scope.$index"
  410. style="margin: 0px; padding: 0px"
  411. >
  412. <el-select
  413. v-model="scope.row.productNo"
  414. placeholder=""
  415. :filter-method="(val) => mySelectFilter(val, scope.row)"
  416. clearable
  417. filterable
  418. @change="
  419. handleProductChange(scope.row.productNo, scope.row)
  420. "
  421. >
  422. <el-option
  423. v-for="item in productionOptions"
  424. :key="item.productNo"
  425. :label="item.productName"
  426. :value="item.productNo"
  427. >
  428. <span class="discribe" style="float: left">{{
  429. item.productName
  430. }}</span>
  431. <span
  432. style="float: right; color: #8492a6; font-size: 13px"
  433. >{{ item.productSpecifications }}</span
  434. >
  435. </el-option>
  436. </el-select>
  437. </el-form-item>
  438. </template>
  439. </el-table-column>
  440. <el-table-column prop="productType" label="类型">
  441. </el-table-column>
  442. <el-table-column prop="productNumber" label="箱数">
  443. <template slot-scope="scope">
  444. <el-form-item
  445. :prop="'productNumber-' + scope.$index"
  446. :name="'productNumber-' + scope.$index"
  447. style="margin: 0px; padding: 0px"
  448. >
  449. <el-input
  450. v-model="scope.row.productNumber"
  451. oninput="value=value.replace(/[^0-9.]/g,'')"
  452. size="small"
  453. clearable
  454. @change="computedPrice(scope.row)"
  455. ></el-input>
  456. </el-form-item>
  457. </template>
  458. </el-table-column>
  459. <el-table-column prop="productUnitPrice" label="单价">
  460. <template slot-scope="scope">
  461. <el-form-item
  462. :prop="'productUnitPrice-' + scope.$index"
  463. :name="'productUnitPrice-' + scope.$index"
  464. style="margin: 0px; padding: 0px"
  465. >
  466. <el-input
  467. v-model="scope.row.productUnitPrice"
  468. size="small"
  469. oninput="value=value.replace(/[^0-9.]/g,'')"
  470. @change="computedPrice(scope.row)"
  471. clearable
  472. ></el-input>
  473. </el-form-item>
  474. </template>
  475. </el-table-column>
  476. <el-table-column prop="productAmounts" label="金额">
  477. <template slot-scope="scope">
  478. {{ scope.row.productAmounts }}
  479. </template>
  480. </el-table-column>
  481. <el-table-column prop="sliceType" label="切片型号">
  482. <template slot-scope="scope">
  483. <el-form-item
  484. :prop="'sliceType-' + scope.$index"
  485. :name="'sliceType-' + scope.$index"
  486. style="margin: 0px; padding: 0px"
  487. >
  488. <el-select
  489. v-model="scope.row.sliceType"
  490. placeholder=""
  491. clearable
  492. filterable
  493. @change="sliceTypeChangeHandler(scope.row)"
  494. >
  495. <el-option
  496. v-for="item in sliceTypeOptions"
  497. :key="item.materielCode"
  498. :label="item.materielName"
  499. :value="item.materielCode"
  500. >
  501. </el-option>
  502. </el-select>
  503. </el-form-item>
  504. </template>
  505. </el-table-column>
  506. <el-table-column prop="colourNumber" label="色号">
  507. <template slot-scope="scope">
  508. <el-form-item
  509. :prop="'colourNumber-' + scope.$index"
  510. :name="'colourNumber-' + scope.$index"
  511. style="margin: 0px; padding: 0px"
  512. >
  513. <el-select
  514. v-model="scope.row.colourNumber"
  515. placeholder=""
  516. clearable
  517. filterable
  518. @change="colourNumberChangeHandler(scope.row)"
  519. >
  520. <el-option
  521. v-for="item in colourNumberOptions"
  522. :key="item.materielCode"
  523. :label="item.materieEncoding + item.materieColorNumber"
  524. :value="item.materielCode"
  525. >
  526. <span class="discribe" style="float: left">{{
  527. item.materieEncoding + item.materieColorNumber
  528. }}</span>
  529. <!-- <span
  530. style="float: right; color: #8492a6; font-size: 13px"
  531. >{{ item.materielCode }}</span
  532. > -->
  533. </el-option>
  534. </el-select>
  535. </el-form-item>
  536. </template>
  537. </el-table-column>
  538. <el-table-column prop="remark" label="备注">
  539. <template slot-scope="scope">
  540. <el-input
  541. v-model="scope.row.remark"
  542. size="small"
  543. clearable
  544. ></el-input>
  545. </template>
  546. </el-table-column>
  547. <el-table-column label="操作">
  548. <template slot-scope="scope">
  549. <el-button
  550. type="danger"
  551. size="small"
  552. @click="deleteProduct(scope.$index)"
  553. >删除</el-button
  554. >
  555. </template>
  556. </el-table-column>
  557. </el-table>
  558. <el-button
  559. class="mt5"
  560. type="primary"
  561. style="width: 100%"
  562. size="small"
  563. @click="addProduct"
  564. >添加货品</el-button
  565. >
  566. <!-- <el-col :span="12" v-show="formData.salePayType == '1'">
  567. <el-form-item prop="earnestMoney" label="定金">
  568. <el-input
  569. v-model="formData.earnestMoney"
  570. clearable
  571. size="small"
  572. />
  573. </el-form-item>
  574. </el-col> -->
  575. <el-col :span="24">
  576. <el-divider>订单备注</el-divider>
  577. </el-col>
  578. <el-col :span="24">
  579. <el-input
  580. type="textarea"
  581. v-model="formData.orderRemark"
  582. placeholder=""
  583. size="normal"
  584. clearable
  585. ></el-input>
  586. </el-col>
  587. <!-- <el-col :span="24">
  588. <el-divider>审计人员数据</el-divider>
  589. </el-col> -->
  590. </el-form>
  591. </el-row>
  592. <div slot="footer" class="dialog-footer">
  593. <el-button type="primary" @click="editConfirm">确 定</el-button>
  594. <el-button @click="cancel">取 消</el-button>
  595. </div>
  596. </el-dialog>
  597. <!-- 自定义弹窗 -->
  598. <el-dialog title="提交" :visible.sync="deliverShow" width="1200px">
  599. <!-- <DialogTemplate
  600. ref="dialogRef"
  601. :groupKey="groupKey"
  602. :rowobj="rowobj"
  603. :subCount="subCount"
  604. :tableCount="tableCount"
  605. :subTableName="subTableName"
  606. @addList="addListHandler"
  607. >
  608. </DialogTemplate> -->
  609. <RetailProvide ref="deliverRef"></RetailProvide>
  610. <span slot="footer" class="dialog-footer">
  611. <el-button @click="deliverShow = false">取 消</el-button>
  612. <!-- <el-button @click="btnSave">保 存</el-button> -->
  613. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  614. </span>
  615. </el-dialog>
  616. <!-- 详情弹窗 -->
  617. <el-dialog title="详情" :visible.sync="detailShow" width="1250px">
  618. <div ref="detailTable" id="detail"></div>
  619. <span slot="footer" class="dialog-footer">
  620. <el-button @click="detailShow = false">取 消</el-button>
  621. <el-button type="primary" @click="detailPrintHandler"
  622. >打 印</el-button
  623. >
  624. </span>
  625. </el-dialog>
  626. <!-- 销售出库弹窗 -->
  627. <el-dialog
  628. title="打印-销售出库单"
  629. :visible.sync="outBoundShow"
  630. width="1000px"
  631. >
  632. <OutBound ref="outBoundRef" :currentRow="currentRow"></OutBound>
  633. <span slot="footer" class="dialog-footer">
  634. <el-button @click="outBoundShow = false">取 消</el-button>
  635. <el-button type="primary" @click="outBoundPrintHandler">
  636. 打印</el-button
  637. >
  638. </span>
  639. </el-dialog>
  640. <!-- 出库详情 -->
  641. <el-dialog title="出库明细" :visible.sync="outStockShow" width="1200px">
  642. <OutStock ref="outStockRef"></OutStock>
  643. <span slot="footer" class="dialog-footer">
  644. <el-button @click="outStockShow = false">关 闭</el-button>
  645. <!-- <el-button @click="btnSave">保 存</el-button> -->
  646. <!-- <el-button type="primary" @click="btnComfirm">确 定</el-button> -->
  647. </span>
  648. </el-dialog>
  649. <div id="printDom"></div>
  650. </div>
  651. </el-card>
  652. </template>
  653. <script>
  654. import {
  655. delTableData,
  656. dragTableInfo,
  657. listTable,
  658. unionListTableData,
  659. getInfoBySqlKey,
  660. btnCommonApi,
  661. addTableData,
  662. batchEdit,
  663. getStatisticList,
  664. getTableList1,
  665. checkOrderNo,
  666. delOrder,
  667. productInvoiceInfo,
  668. addProductInvoice,
  669. updateProductInvoice,
  670. queryMaterielList,
  671. } from "@/api/tablelist/commonTable";
  672. import {
  673. saleOrderList,
  674. getRoleUser,
  675. addRetailOrder,
  676. getRetailOrderInfo,
  677. editRetailOrder,
  678. retailProductInvoiceInfo,
  679. submitRetailOrder,
  680. cancelRetailOrder,
  681. } from "@/api/system/retailMange.js";
  682. import { listData } from "@/api/system/tenant/data";
  683. import { getToken } from "@/utils/auth";
  684. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  685. import { camelCase, toUnderline } from "@/utils";
  686. import { inputDisableComplete } from "@/utils/other";
  687. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  688. import { checkRole } from "@/utils/permission";
  689. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  690. import {
  691. queryDropDownBoxData,
  692. getSaleOrderProductionList,
  693. } from "@/api/dragform/form";
  694. import { v4 as uuidv4 } from "uuid";
  695. import { mapState } from "vuex";
  696. import moment from "moment";
  697. import Deliver from "@/views/orderMange/components/dialogForm/Deliver.vue";
  698. import RetailProvide from "@/views/orderMange/components/dialogForm/RetailProvide.vue";
  699. import OutStock from "@/views/orderMange/components/dialogForm/OutStock.vue";
  700. import OutBound from "@/views/orderMange/components/dialogForm/OutBound.vue";
  701. import outBoundPrint from "@/utils/print/outBoundPrint";
  702. import { listCustomer } from "@/api/system/customer";
  703. import { numToCapital } from "@/utils/other";
  704. export default {
  705. name: "retailMange",
  706. dicts: [
  707. "payment_method",
  708. "direction_of_twist",
  709. "retail_order_pay_method",
  710. "sales_order_status",
  711. ],
  712. components: {
  713. Queryfrom,
  714. Menu,
  715. DialogTemplate,
  716. Deliver,
  717. OutBound,
  718. RetailProvide,
  719. OutStock,
  720. },
  721. data() {
  722. return {
  723. outStockShow: false, //出库详情弹窗
  724. totalMoney: "", //合计金额 小写
  725. createById: "", //创建者id
  726. salesmanList: [], //销售员列表
  727. isLeader: false, //当前登录用户是否为领导
  728. selection: [], //勾选的数据
  729. // 出库单 start
  730. outBoundShow: false,
  731. // 出库单 end
  732. // 发货 start
  733. deliverShow: false,
  734. // 发货 end
  735. // 出库单 start
  736. // 出库单 end
  737. myDelIds: [], //新增接口 删除的id
  738. // 详情弹窗数据
  739. detailShow: false,
  740. printDomData: "",
  741. // k-form-build组件渲染弹窗
  742. kOpen: false,
  743. // 新的自定义数据 start
  744. orderType: 0, //新的条件查询参数
  745. productIds: [], //货品Ids
  746. isEdit: false,
  747. formData: {
  748. //订单表数据
  749. saleNo: "", //合同号
  750. saleCustomNo: "", //客户编号
  751. saleDate: "", //销售单日期
  752. saleOrderEstimatedTime: "", //预计下单时间
  753. saleLeadTime: "1", //交货周期
  754. deliveryDate: "", //交货日期
  755. saleAmounts: "", //合计金额 小写
  756. saleAmountInWords: "", //合计金额 大写
  757. salePayType: "1", //支付方式
  758. earnestMoney: "", //定金
  759. salesman: "", //业务员
  760. saleLeader: "", //业务主管
  761. finance: "", //财务部
  762. production: "", //生产部
  763. saleApprover: "", //批准人
  764. customAddress: "", //客户地址
  765. customCountryType: "", //国家类型
  766. contactPerson: "", //联系人
  767. // 货品明细表数据
  768. lotNumber: "", //批号
  769. productNo: "", //货品号
  770. productName: "", //货品名称
  771. productNumber: "", //销售数量
  772. productWeight: "", //销售重量kg
  773. productUnitPrice: "", //单价
  774. productAmounts: "", //金额
  775. sliceType: "", //切片类型
  776. sliceTypeLabel: "",
  777. colourNumberLabel: "",
  778. colourNumber: "", //色号
  779. remark: "", //备注
  780. // 工艺表
  781. orderRemark: "",
  782. },
  783. sliceTypeOptions: [], //切片型号选项
  784. colourNumberOptions: [], //色号选项
  785. allProductionOptions: [], //所有产品选项
  786. productionOptions: [],
  787. customerOptions: [],
  788. productionTableData: [
  789. // {
  790. // productNo: "", //货品名称
  791. // productNumber: 2, //销售数量
  792. // productWeight: 1, //销售重量kg
  793. // productUnitPrice: 20, //单价
  794. // productAmounts: 20, //金额
  795. // remark: "", //备注
  796. // },
  797. ],
  798. rules: {
  799. saleNo: [
  800. {
  801. required: true,
  802. message: "请输入合同号",
  803. trigger: "blur",
  804. },
  805. // {
  806. // validator: this.validateOrderNo,
  807. // trigger: "blur",
  808. // },
  809. ],
  810. saleDate: [
  811. {
  812. required: true,
  813. message: "请选择日期",
  814. trigger: "change",
  815. },
  816. ],
  817. // lotNumber: [
  818. // {
  819. // required: true,
  820. // message: "请输入批号",
  821. // trigger: "blur",
  822. // },
  823. // ],
  824. saleCustomNo: [
  825. {
  826. required: true,
  827. message: "请选择客户",
  828. trigger: "change",
  829. },
  830. ],
  831. saleOrderEstimatedTime: [
  832. {
  833. required: true,
  834. message: "请选择预计下单时间",
  835. trigger: "change",
  836. },
  837. ],
  838. saleLeadTime: [
  839. {
  840. required: true,
  841. message: "请输入交货天数",
  842. trigger: "blur",
  843. },
  844. ],
  845. // earnestMoney: [
  846. // {
  847. // validator: this.validateEarnestMoney,
  848. // trigger: "blur",
  849. // },
  850. // ],
  851. },
  852. // end
  853. // 绑定按钮dialog
  854. btnDialogVisible: false,
  855. // 绑定修改dialog
  856. groupKey: "",
  857. // 遮罩层
  858. loading: true,
  859. // 选中数组
  860. ids: [],
  861. // 非单个禁用
  862. single: true,
  863. // 非多个禁用
  864. multiple: true,
  865. // 显示统计
  866. showCount: true,
  867. // 显示搜索条件
  868. showSearch: true,
  869. // 总条数
  870. total: 0,
  871. // 用户表格数据
  872. tableList: [],
  873. // 弹出层标题
  874. title: "",
  875. // 日期范围
  876. dateRange: [],
  877. // 表单参数
  878. form: {},
  879. // cru 弹窗
  880. open: false,
  881. // excel共通导入数据
  882. upload: {
  883. // 是否显示弹出层
  884. open: false,
  885. // 弹出层标题(
  886. title: "",
  887. // 是否禁用上传
  888. isUploading: false,
  889. // 是否更新已经存在的数据
  890. updateSupport: 0,
  891. // 设置上传的请求头部
  892. headers: { Authorization: "Bearer " + getToken() },
  893. // 上传的地址
  894. url: process.env.VUE_APP_BASE_API1 + "common/uploadData",
  895. },
  896. // 排序方式 默认降序
  897. sortOrder: true,
  898. // 共通查询参数接受子组件的参数
  899. queryParams: {
  900. saleOrderTechnologyNo: "retailOrder",
  901. pageNum: 1, // 第几页
  902. pageSize: 10, // 每页大小
  903. orderByColumn: "", // 根据某列排序
  904. isAsc: "", // desc(降序)或 asc(升序)
  905. saleOrderOrderType: "",
  906. // 基本查询参数
  907. basicMap: {
  908. tableName: "drag_form",
  909. },
  910. // 当前表字段筛选参数
  911. queryMap: {
  912. queryCriteriaValue: "",
  913. },
  914. },
  915. // 列信息
  916. columns: {},
  917. // 当前模版信息
  918. templateInfo: {},
  919. // 查询条件
  920. queryFromWhere: {},
  921. // 当前table唯一标识
  922. tableKey: null,
  923. // 当前表名称
  924. tableName: null,
  925. //存放html代码块
  926. iframeUrl: "",
  927. //存放表单渲染数据
  928. jsonData: {},
  929. // 回显表格数据,
  930. defaultValue: {},
  931. // 统计card
  932. statisticList: [],
  933. // 样式表
  934. styleList: [],
  935. // 字典样式对象
  936. dictStyleObj: {},
  937. // 操作列 按钮数据
  938. excuteBtnArr: [],
  939. // 下拉框动态数据
  940. dynamicData: {},
  941. // 当前点击按钮的数据
  942. currentBtnData: {},
  943. // 修改选中行
  944. rowobj: {},
  945. // 该行的统计信息
  946. subCount: [],
  947. tableCount: [],
  948. // 弹窗新增数据
  949. addLists: [],
  950. subTableName: "",
  951. // 当前点击行的数据
  952. currentRow: {},
  953. };
  954. },
  955. created() {
  956. // 得到当前展示的table的唯一标识
  957. this.tableKey = this.$route.query.tableKey;
  958. },
  959. watch: {
  960. totalMoney: {
  961. handler(newVal, oldVal) {
  962. if (isNaN(Number(newVal))) {
  963. this.formData.saleAmountInWords = "零";
  964. } else {
  965. const ntc = new numToCapital();
  966. this.formData.saleAmountInWords = ntc.uppercase(newVal);
  967. }
  968. },
  969. deep: true,
  970. immediate: true,
  971. },
  972. },
  973. async mounted() {
  974. await this.getDropDownData();
  975. },
  976. computed: {
  977. isShowExcuteCol() {
  978. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  979. },
  980. ...mapState({
  981. nickName: (state) => state.user.nickName,
  982. userInfo: (state) => state.user,
  983. }),
  984. },
  985. methods: {
  986. // 出库单回调
  987. async myPrintOutBoundHandler(row) {
  988. console.log("row", row);
  989. this.currentRow = row;
  990. this.outBoundShow = true;
  991. this.$nextTick(() => {
  992. this.$refs.outBoundRef.getTableData(row);
  993. });
  994. },
  995. // 出库详情回调
  996. handleOutDetail(row) {
  997. this.outStockShow = true;
  998. this.$nextTick(() => {
  999. this.$refs.outStockRef.getOutStockDetail(row);
  1000. });
  1001. },
  1002. // 业务员改变回调
  1003. salemanChange(val) {
  1004. if (!val) {
  1005. this.createById = "";
  1006. return;
  1007. } else {
  1008. this.createById = this.salesmanList.find(
  1009. (item) => item.value == val
  1010. ).id;
  1011. }
  1012. },
  1013. // 生成合同号
  1014. getSaleNo() {
  1015. let timeStr = moment().format("YYYYMMDD");
  1016. for (var i = 0; i < 5; i++) {
  1017. timeStr += parseInt(Math.random() * 10);
  1018. }
  1019. return timeStr;
  1020. },
  1021. // 自定义筛选方法
  1022. mySelectFilter(value, row) {
  1023. console.log(value);
  1024. // row.productNo = value;
  1025. if (value) {
  1026. let target = [];
  1027. // 在全部列表中查找
  1028. target = this.allProductionOptions.filter((item) =>
  1029. item.productName.includes(value)
  1030. );
  1031. console.log(target);
  1032. if (target.length) {
  1033. this.productionOptions = target;
  1034. return true;
  1035. } else {
  1036. return false;
  1037. }
  1038. } else {
  1039. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1040. }
  1041. },
  1042. // 出库单回调
  1043. async myPrintOutBoundHandler(row, data) {
  1044. console.log("row", row);
  1045. this.currentRow = row;
  1046. this.outBoundShow = true;
  1047. this.$nextTick(() => {
  1048. this.$refs.outBoundRef.getTableData(row);
  1049. });
  1050. },
  1051. // 出库单打印回调
  1052. async outBoundPrintHandler() {
  1053. let res = await this.$refs.outBoundRef.getPrintData();
  1054. console.log(res);
  1055. if (res.flag) {
  1056. res.data.form.printUser = this.nickName;
  1057. outBoundPrint(res.data, "printDom", true);
  1058. }
  1059. },
  1060. // 产品名称改变
  1061. handleProductChange(productNo, row) {
  1062. if (!productNo) {
  1063. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1064. return;
  1065. }
  1066. row.productName = this.productionOptions.find(
  1067. (item) => item.productNo == productNo
  1068. )?.productName;
  1069. row.productType = this.productionOptions.find(
  1070. (item) => item.productNo == productNo
  1071. )?.productType;
  1072. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1073. },
  1074. // 订单类型改变回调
  1075. orderTypeChange(type) {
  1076. this.getList(false, type);
  1077. },
  1078. // 重置审计表单数据
  1079. resetFormData() {
  1080. Object.assign(this.formData, {
  1081. //订单表数据
  1082. saleNo: this.getSaleNo(), //合同号
  1083. saleCustomNo: "", //客户编号
  1084. saleDate: moment(new Date()).format("YYYY-MM-DD"), //销售单日期
  1085. saleOrderEstimatedTime: moment(new Date()).format("YYYY-MM-DD"), //预计下单时间
  1086. saleLeadTime: "1", //交货周期
  1087. deliveryDate: moment(new Date()).format("YYYY-MM-DD"),
  1088. saleAmounts: "", //合计金额 小写
  1089. saleAmountInWords: "", //合计金额 大写
  1090. salePayType: "1", //支付方式
  1091. earnestMoney: "",
  1092. salesman: "", //业务员
  1093. saleLeader: "", //业务主管
  1094. finance: "", //财务部
  1095. production: "", //生产部
  1096. saleApprover: "", //批准人
  1097. customAddress: "", //客户地址
  1098. customCountryType: "", //国家类型
  1099. contactPerson: "", //联系人
  1100. // 货品明细表数据
  1101. lotNumber: "", //批号
  1102. productNo: "", //货品号
  1103. productName: "", //货品名称
  1104. productNumber: "", //销售数量
  1105. productWeight: "", //销售重量kg
  1106. productUnitPrice: "", //单价
  1107. productAmounts: "", //金额
  1108. sliceType: "", //切片类型
  1109. sliceTypeLabel: "",
  1110. colourNumberLabel: "",
  1111. colourNumber: "", //色号
  1112. remark: "", //备注
  1113. // 工艺表
  1114. craftGrid: "", //网络
  1115. craftOil: "", //油剂
  1116. craftPackage: "", //卷装
  1117. craftColorFastness: "", //色牢度
  1118. directionOfTwist: "",
  1119. craftOther: "", //其它工艺要求
  1120. craftMark: "", //包装/贴唛
  1121. shippingMethod: "", //运输方式
  1122. });
  1123. this.productionTableData = [];
  1124. },
  1125. // 自定义的小计计算方法
  1126. getSummaries(param) {
  1127. const { columns, data } = param;
  1128. console.log(columns, data);
  1129. const sums = [];
  1130. columns.forEach((column, index) => {
  1131. if (index === 0) {
  1132. sums[index] = "小计";
  1133. return;
  1134. }
  1135. const values = data.map((item) => Number(item[column.property]));
  1136. if (
  1137. index === 1 ||
  1138. index === 5 ||
  1139. index === 6 ||
  1140. index === 7 ||
  1141. index === 8
  1142. ) {
  1143. sums[index] = "";
  1144. } else if (!values.every((value) => isNaN(value))) {
  1145. sums[index] = values
  1146. .reduce((prev, curr) => {
  1147. const value = Number(curr);
  1148. if (!isNaN(value)) {
  1149. return prev + curr;
  1150. } else {
  1151. return prev;
  1152. }
  1153. }, 0)
  1154. ?.toFixed(2);
  1155. console.log(sums[index], index);
  1156. if (index == 4) {
  1157. this.totalMoney = sums[index];
  1158. }
  1159. } else {
  1160. sums[index] = "N/A";
  1161. }
  1162. });
  1163. return sums;
  1164. },
  1165. // 货品表格数据删除回调
  1166. deleteProduct(index) {
  1167. this.productionTableData.splice(index, 1);
  1168. this.initTableValidate();
  1169. },
  1170. // 货品表格数据新增回调
  1171. addProduct() {
  1172. this.productionTableData.push({
  1173. saleProductNo: uuidv4(),
  1174. productNo: "", //货品编号
  1175. productType: "", //类型
  1176. productName: "", //货品名称
  1177. productNumber: "", //销售数量
  1178. productWeight: "", //销售重量kg
  1179. productUnitPrice: "", //单价
  1180. productAmounts: "", //金额
  1181. sliceType: "022", //切片类型 初始为 切片
  1182. sliceTypeLabel: "",
  1183. colourNumberLabel: "",
  1184. colourNumber: "", //色号
  1185. remark: "", //备注
  1186. });
  1187. // 添加校验规则
  1188. this.initTableValidate();
  1189. },
  1190. // 自定义校验规则
  1191. validateTableField(rule, value, callback) {
  1192. console.log("校验规则", rule, value);
  1193. let { message, field } = rule;
  1194. let index = field.split("-")[1],
  1195. fieldName = field.split("-")[0];
  1196. console.log(
  1197. index,
  1198. fieldName,
  1199. this.productionTableData[Number(index)][fieldName]
  1200. );
  1201. if (!this.productionTableData[Number(index)][fieldName]) {
  1202. callback(new Error(message));
  1203. } else {
  1204. callback();
  1205. }
  1206. },
  1207. // 初始化校验规则
  1208. initTableValidate() {
  1209. let length = this.productionTableData.length;
  1210. for (let i = 0; i < length; i++) {
  1211. this.rules["productNo-" + i] = [
  1212. {
  1213. // required: true,
  1214. message: "请选择货品",
  1215. trigger: "change",
  1216. validator: this.validateTableField,
  1217. },
  1218. ];
  1219. this.rules["productNumber-" + i] = [
  1220. {
  1221. // required: true,
  1222. message: "请输入数量",
  1223. trigger: "blur",
  1224. validator: this.validateTableField,
  1225. },
  1226. ];
  1227. this.rules["productUnitPrice-" + i] = [
  1228. {
  1229. // required: true,
  1230. message: "请输入单价",
  1231. trigger: "blur",
  1232. validator: this.validateTableField,
  1233. },
  1234. ];
  1235. this.rules["sliceType-" + i] = [
  1236. {
  1237. // required: true,
  1238. message: "请选择切片类型",
  1239. trigger: "change",
  1240. validator: this.validateTableField,
  1241. },
  1242. ];
  1243. this.rules["colourNumber-" + i] = [
  1244. {
  1245. // required: true,
  1246. message: "请选择色号",
  1247. trigger: "change",
  1248. validator: this.validateTableField,
  1249. },
  1250. ];
  1251. }
  1252. console.log(this.rules);
  1253. },
  1254. // 客户名称改变回调
  1255. customChangeHandler(val) {
  1256. // if (!val) return;
  1257. let customData = this.customerOptions.find(
  1258. (item) => item.customNo == val
  1259. );
  1260. this.formData.customAddress = customData?.customAddress || "无";
  1261. this.formData.customCountryType = customData?.customCountryType || "无";
  1262. this.formData.contactPerson = customData?.contactPerson || "无";
  1263. },
  1264. // 获取销售员角色列表
  1265. async getRoleUser() {
  1266. try {
  1267. let res = await getRoleUser("salesman");
  1268. if (res.code == 200) {
  1269. this.salesmanList = res.data.map((item) => {
  1270. return {
  1271. label: item.nickName,
  1272. value: item.nickName,
  1273. id: item.userId,
  1274. };
  1275. });
  1276. } else {
  1277. this.$message.error("获取销售员角色列表失败");
  1278. }
  1279. } catch (error) {
  1280. console.log(error);
  1281. }
  1282. },
  1283. //审计新增
  1284. async addHandler() {
  1285. this.isEdit = false;
  1286. await this.getDropDownData();
  1287. // 判断是否是销售员
  1288. console.log(this.userInfo);
  1289. this.isLeader = !this.userInfo.roles.includes("salesman");
  1290. if (!this.isLeader) {
  1291. this.createById = this.userInfo.userId;
  1292. }
  1293. await this.getRoleUser();
  1294. this.resetFormData();
  1295. this.title = "新增零售单";
  1296. this.open = true;
  1297. this.$nextTick(() => {
  1298. this.$refs.formDataRef.resetFields();
  1299. this.formData.orderRemark = "";
  1300. // this.$refs["formDataRef"].clearValidate();
  1301. });
  1302. },
  1303. // 获取下拉框数据
  1304. async getDropDownData() {
  1305. try {
  1306. // let payLoad = [
  1307. // {
  1308. // basicMap: {
  1309. // tableName: "production",
  1310. // },
  1311. // },
  1312. // {
  1313. // basicMap: {
  1314. // tableName: "customer",
  1315. // },
  1316. // },
  1317. // ];
  1318. // let res = await queryDropDownBoxData(payLoad);
  1319. // 新的获取客户选项数据的接口
  1320. let res = await listCustomer({ isEnablePaging: false });
  1321. if (res.code == 200) {
  1322. // let { customer } = res.data.resultMap;
  1323. // this.allProductionOptions = production || [];
  1324. // this.productionOptions =
  1325. // this.allProductionOptions.slice(0, 100) || [];
  1326. this.customerOptions = res.rows || [];
  1327. } else {
  1328. throw Error("获取下拉框数据失败");
  1329. }
  1330. let proRes = await getSaleOrderProductionList();
  1331. if (proRes.code == 200) {
  1332. // let { production, customer } = proRes.data.resultMap;
  1333. this.allProductionOptions = proRes.data || [];
  1334. this.productionOptions =
  1335. this.allProductionOptions.slice(0, 500) || [];
  1336. } else {
  1337. throw Error("获取下拉框数据失败");
  1338. }
  1339. } catch (error) {
  1340. console.log(error);
  1341. }
  1342. // 色号数据
  1343. try {
  1344. let payLoad = [
  1345. {
  1346. basicMap: {
  1347. tableName: "materiel",
  1348. },
  1349. conditionMap: {
  1350. materiel_species: ["1"],
  1351. },
  1352. },
  1353. ];
  1354. // let res = await queryDropDownBoxData(payLoad);
  1355. let res = await queryMaterielList();
  1356. if (res.code == 200) {
  1357. // let { materiel } = res.data;
  1358. this.colourNumberOptions = res.data || [];
  1359. } else {
  1360. throw Error("获取下拉框数据失败");
  1361. }
  1362. } catch (error) {
  1363. console.log(error);
  1364. }
  1365. // 切片型号
  1366. try {
  1367. let payLoad = [
  1368. {
  1369. basicMap: {
  1370. tableName: "materiel",
  1371. },
  1372. conditionMap: {
  1373. materiel_species: ["6"],
  1374. },
  1375. },
  1376. ];
  1377. let res = await queryDropDownBoxData(payLoad);
  1378. if (res.code == 200) {
  1379. console.log(res.data.resultMap);
  1380. let { materiel } = res.data.resultMap;
  1381. this.sliceTypeOptions = materiel || [];
  1382. } else {
  1383. throw Error("获取下拉框数据失败");
  1384. }
  1385. } catch (error) {
  1386. console.log(error);
  1387. }
  1388. },
  1389. //
  1390. // 获取row-key
  1391. getRowKey(row) {
  1392. return row[
  1393. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  1394. ];
  1395. },
  1396. /** 查询列表 */
  1397. async getList() {
  1398. this.loading = true;
  1399. try {
  1400. let res = await saleOrderList(this.queryParams);
  1401. console.log(res);
  1402. if (res.code == 200) {
  1403. this.tableList = res.rows;
  1404. console.log(this.dict.type.sales_order_status);
  1405. this.tableList.forEach((item) => {
  1406. item.listClass = this.dict.type.sales_order_status.find(
  1407. (i) => i.value == item.status
  1408. ).raw.listClass;
  1409. });
  1410. this.total = res.total;
  1411. } else {
  1412. this.$message.error(res.msg);
  1413. }
  1414. this.loading = false;
  1415. } catch (error) {
  1416. console.log(error);
  1417. this.loading = false;
  1418. }
  1419. },
  1420. // 校验定金
  1421. validateEarnestMoney(rule, value, callback) {
  1422. console.log(value);
  1423. if (this.formData.salePayType == "1") {
  1424. if (value == "" || value == null || value == undefined) {
  1425. callback(new Error("请输入定金金额"));
  1426. } else {
  1427. callback();
  1428. }
  1429. } else {
  1430. callback();
  1431. }
  1432. },
  1433. // 校验订单号是否有效
  1434. async validateOrderNo(rule, value, callback) {
  1435. console.log(value);
  1436. // let saleNo = this.formData.orderNo;
  1437. // 检验订单号合法
  1438. let checkNoPayload = {
  1439. saleNo: value,
  1440. };
  1441. if (this.isEdit) {
  1442. checkNoPayload.id = this.formData.id;
  1443. }
  1444. let result = await checkOrderNo(checkNoPayload);
  1445. if (result.code == 200) {
  1446. if (result.data) {
  1447. callback();
  1448. } else {
  1449. callback(new Error("合同号已存在"));
  1450. }
  1451. } else {
  1452. callback(new Error("校验失败,请稍后再试"));
  1453. }
  1454. },
  1455. // 校验表格数据
  1456. validateTableData() {
  1457. if (this.productionTableData.length == 0) {
  1458. return {
  1459. res: false,
  1460. msg: "请添加货品明细",
  1461. };
  1462. }
  1463. let res = this.productionTableData.every((item) => {
  1464. return (
  1465. item.productNo &&
  1466. item.productNumber &&
  1467. item.productUnitPrice &&
  1468. item.productAmounts &&
  1469. item.sliceType &&
  1470. item.colourNumber
  1471. );
  1472. });
  1473. if (!res) {
  1474. return {
  1475. res: false,
  1476. msg: "请填写完整货品明细",
  1477. };
  1478. }
  1479. return {
  1480. res: true,
  1481. msg: "",
  1482. };
  1483. },
  1484. // 审计 提交编辑结果按钮回调
  1485. async editConfirm() {
  1486. // let tableValidate = this.validateTableData();
  1487. // if (!tableValidate.res) {
  1488. // this.$message.warning(tableValidate.msg);
  1489. // }
  1490. this.$refs.formDataRef.validate(async (valid) => {
  1491. if (valid) {
  1492. console.log(valid);
  1493. let {
  1494. id,
  1495. //订单表数据
  1496. saleNo,
  1497. saleCustomNo,
  1498. saleDate,
  1499. saleOrderEstimatedTime,
  1500. saleLeadTime,
  1501. deliveryDate,
  1502. saleAmounts,
  1503. saleAmountInWords,
  1504. salePayType,
  1505. salesman,
  1506. customAddress,
  1507. customCountryType, //国家类型
  1508. contactPerson, //联系人
  1509. // 工艺表数据
  1510. orderRemark,
  1511. } = this.formData;
  1512. let payload = {
  1513. createById: this.createById,
  1514. saleOrderTechnologyNo: "retailOrder",
  1515. saleNo,
  1516. saleCustomNo,
  1517. saleDate,
  1518. saleOrderEstimatedTime,
  1519. saleLeadTime,
  1520. deliveryDate,
  1521. saleAmounts,
  1522. saleAmountInWords,
  1523. salePayType,
  1524. customAddress, //客户地址
  1525. customCountryType, //国家类型
  1526. contactPerson, //联系人
  1527. remark: orderRemark,
  1528. salesman: this.isLeader ? salesman : this.nickName,
  1529. status: 1,
  1530. };
  1531. payload.saleProductsList = this.productionTableData;
  1532. if (this.isEdit) {
  1533. payload.id = id;
  1534. let res = await editRetailOrder(payload);
  1535. if (res.code === 200) {
  1536. this.$message.success("修改成功");
  1537. this.open = false;
  1538. this.getList();
  1539. } else {
  1540. this.$message.error("修改失败");
  1541. }
  1542. } else {
  1543. //新增
  1544. let res = await addRetailOrder(payload);
  1545. if (res.code == 200) {
  1546. this.$message.success("添加成功");
  1547. this.open = false;
  1548. this.getList();
  1549. } else {
  1550. this.$message.error("添加失败");
  1551. }
  1552. }
  1553. // Object.keys(saleValue).map((k) => {
  1554. // saleData.commMap[k] = saleValue[k];
  1555. // });
  1556. } else {
  1557. this.$message.warning("请填写完整信息");
  1558. }
  1559. });
  1560. },
  1561. // 审计 编辑回调
  1562. async handleEdit(index, row) {
  1563. console.log(row);
  1564. let { saleOrderSaleNo } = row;
  1565. try {
  1566. let payLoad = [
  1567. {
  1568. basicMap: {
  1569. tableName: "sale_order",
  1570. },
  1571. conditionMap: {
  1572. sale_no: [saleOrderSaleNo],
  1573. },
  1574. },
  1575. {
  1576. basicMap: {
  1577. tableName: "sale_products",
  1578. },
  1579. conditionMap: {
  1580. sale_order_no: [saleOrderSaleNo],
  1581. },
  1582. },
  1583. {
  1584. basicMap: {
  1585. tableName: "sale_craft",
  1586. },
  1587. conditionMap: {
  1588. sale_order_no: [saleOrderSaleNo],
  1589. },
  1590. },
  1591. ];
  1592. let res = await queryDropDownBoxData(payLoad);
  1593. if (res.code == 200) {
  1594. this.isEdit = true;
  1595. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1596. Object.assign(this.formData, {
  1597. ...sale_craft[0],
  1598. ...sale_order[0],
  1599. });
  1600. let { saleDate, saleOrderEstimatedTime, deliveryDate } =
  1601. sale_order[0];
  1602. saleDate && (this.formData.saleDate = new Date(saleDate));
  1603. saleOrderEstimatedTime &&
  1604. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1605. deliveryDate && (this.formData.deliveryDate = new Date(deliveryDate));
  1606. this.productIds = sale_products.map((item) => item.saleProductNo);
  1607. await this.getDropDownData();
  1608. this.productionTableData = sale_products.map((item) => {
  1609. item.productType = this.allProductionOptions.find(
  1610. (i) => item.productNo == i.productNo
  1611. )?.productType;
  1612. return item;
  1613. });
  1614. if (this.formData.saleCustomNo) {
  1615. this.customChangeHandler(this.formData.saleCustomNo);
  1616. }
  1617. this.title = "编辑审计单";
  1618. this.open = true;
  1619. }
  1620. } catch (error) {
  1621. console.log(error);
  1622. }
  1623. },
  1624. // 审计 批量删除回调
  1625. async batchDelete() {
  1626. if (!this.ids.length) return;
  1627. try {
  1628. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1629. confirmButtonText: "确定",
  1630. cancelButtonText: "取消",
  1631. type: "warning",
  1632. });
  1633. let orderPayload = {
  1634. basicMap: {
  1635. tableName: "sale_order",
  1636. },
  1637. conditionMap: {
  1638. saleNo: this.ids,
  1639. },
  1640. };
  1641. let productsPayload = {
  1642. basicMap: {
  1643. tableName: "sale_products",
  1644. },
  1645. conditionMap: {
  1646. saleOrderNo: this.ids,
  1647. },
  1648. };
  1649. let craftPayload = {
  1650. basicMap: {
  1651. tableName: "sale_craft",
  1652. },
  1653. conditionMap: {
  1654. saleOrderNo: this.ids,
  1655. },
  1656. };
  1657. let orderRes = await delTableData(orderPayload);
  1658. // let productRes = await delTableData(productsPayload);
  1659. // let craftRes = await delTableData(craftPayload);
  1660. if (orderRes.code == 200) {
  1661. this.$message.success("删除成功");
  1662. this.getList();
  1663. } else {
  1664. this.$message.error("删除失败");
  1665. throw Error("删除失败");
  1666. }
  1667. this.ids = [];
  1668. this.$refs.tableRef.clearSelection();
  1669. } catch (error) {
  1670. console.log(error);
  1671. }
  1672. },
  1673. // 计算金额
  1674. computedPrice(row) {
  1675. let { productNumber, productUnitPrice } = row;
  1676. console.log(
  1677. "productNumber, productUnitPrice",
  1678. productNumber,
  1679. productUnitPrice
  1680. );
  1681. row.productAmounts = (
  1682. Number(productNumber) * Number(productUnitPrice)
  1683. ).toFixed(2);
  1684. },
  1685. isUpperCase(char) {
  1686. return char === char.toUpperCase();
  1687. },
  1688. // 下划线命名转驼峰命名
  1689. toUnderScoreCase(str) {
  1690. if (str === null) {
  1691. return null;
  1692. }
  1693. let sb = "";
  1694. // 前置字符是否大写
  1695. let preCharIsUpperCase = true;
  1696. // 当前字符是否大写
  1697. let curreCharIsUpperCase = true;
  1698. // 下一字符是否大写
  1699. let nexteCharIsUpperCase = true;
  1700. for (let i = 0; i < str.length; i++) {
  1701. let c = str.charAt(i);
  1702. if (i > 0) {
  1703. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  1704. } else {
  1705. preCharIsUpperCase = false;
  1706. }
  1707. curreCharIsUpperCase = isUpperCase(c);
  1708. if (i < str.length - 1) {
  1709. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  1710. }
  1711. if (
  1712. preCharIsUpperCase &&
  1713. curreCharIsUpperCase &&
  1714. !nexteCharIsUpperCase
  1715. ) {
  1716. sb += SEPARATOR;
  1717. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  1718. sb += SEPARATOR;
  1719. }
  1720. sb += c.toLowerCase();
  1721. }
  1722. return sb;
  1723. },
  1724. // 处理列表信息
  1725. columnsHandler(columns) {
  1726. let resArr = [];
  1727. console.log(columns, 111);
  1728. columns.forEach((item) => {
  1729. for (const key in item) {
  1730. let tempObj = {};
  1731. tempObj.key = camelCase(key);
  1732. tempObj.value = item[key];
  1733. resArr.push(tempObj);
  1734. }
  1735. });
  1736. console.log(resArr, 222);
  1737. return resArr;
  1738. },
  1739. // 取消按钮
  1740. cancel() {
  1741. this.open = false;
  1742. // this.reset();
  1743. },
  1744. // k-form-build 取消按钮
  1745. kCancel() {
  1746. this.kOpen = false;
  1747. // this.reset();
  1748. },
  1749. // 分页查询
  1750. pageList(row) {
  1751. // 调用子组件-》携带子组件参数请求后台
  1752. this.$refs.mychild.pageList(
  1753. row == undefined
  1754. ? {
  1755. limit: this.queryParams.pageSize,
  1756. page: this.queryParams.pageNum,
  1757. }
  1758. : row
  1759. );
  1760. },
  1761. // 多选框选中数据
  1762. handleSelectionChange(selection) {
  1763. // this.ids = selection.map(
  1764. // (item) =>
  1765. // item[
  1766. // camelCase(
  1767. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  1768. // )
  1769. // ]
  1770. // );
  1771. this.selection = selection;
  1772. this.myDelIds = selection.map((item) => item.saleOrderId);
  1773. console.log(this.myDelIds);
  1774. this.ids = selection.map((item) => item.saleOrderSaleNo);
  1775. this.single = selection.length != 1;
  1776. this.multiple = !selection.length;
  1777. },
  1778. // 更多操作触发
  1779. handleCommand(command, row) {
  1780. switch (command) {
  1781. case "handleResetPwd":
  1782. this.handleResetPwd(row);
  1783. break;
  1784. case "handleAuthRole":
  1785. this.handleAuthRole(row);
  1786. break;
  1787. default:
  1788. break;
  1789. }
  1790. },
  1791. /** 新增按钮操作 */
  1792. handleAdd(row) {
  1793. // this.reset();
  1794. this.defaultValue = {};
  1795. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1796. if (!data || !data.dfVueTemplate) {
  1797. this.jsonData = false;
  1798. this.$message.error("当前表格未绑定表单!");
  1799. return;
  1800. }
  1801. if (data.dfFormSql) {
  1802. let dynamicData = JSON.parse(data.dfFormSql);
  1803. Object.assign(this.dynamicData, dynamicData);
  1804. }
  1805. this.jsonData = JSON.parse(data.dfVueTemplate);
  1806. this.open = true;
  1807. this.title = "添加信息";
  1808. this.form.password = this.initPassword;
  1809. this.$nextTick(() => {
  1810. this.$refs.addFromRef.reset();
  1811. inputDisableComplete();
  1812. });
  1813. });
  1814. },
  1815. longestCommonSubstring(strs) {
  1816. if (!strs || strs.includes("")) return "";
  1817. let str1_Length = strs[0].length;
  1818. let str_Nums = strs.length;
  1819. let flag = 0;
  1820. for (let i = 0; i < str1_Length && flag == 0; i++) {
  1821. let char = strs[0][i];
  1822. for (var j = 1; j < str_Nums; j++) {
  1823. if (char !== strs[j][i] || i == strs[j].length) {
  1824. return strs[1].substring(0, i);
  1825. }
  1826. }
  1827. }
  1828. return strs[0];
  1829. },
  1830. // 绑定dialog对话框关闭
  1831. handleClose() {
  1832. this.btnDialogVisible = false;
  1833. },
  1834. getLastUppercaseWord(text) {
  1835. const pattern = /\b[A-Z][a-z]*\b/g;
  1836. const matches = [...text.matchAll(pattern)];
  1837. if (matches.length > 0) {
  1838. const lastMatch = matches[matches.length - 1][0];
  1839. return lastMatch;
  1840. } else {
  1841. return null;
  1842. }
  1843. },
  1844. // 初始化数据
  1845. initData(data) {
  1846. let {
  1847. id,
  1848. //订单表数据
  1849. saleNo,
  1850. saleCustomNo,
  1851. saleDate,
  1852. saleOrderEstimatedTime,
  1853. saleLeadTime,
  1854. deliveryDate,
  1855. saleAmounts,
  1856. saleAmountInWords,
  1857. salePayType,
  1858. salesman,
  1859. customAddress,
  1860. customCountryType, //国家类型
  1861. contactPerson, //联系人
  1862. // 工艺表数据
  1863. remark,
  1864. // 产品列表
  1865. saleProductsList,
  1866. } = data;
  1867. Object.assign(this.formData, {
  1868. id,
  1869. //订单表数据
  1870. saleNo,
  1871. saleCustomNo,
  1872. saleDate,
  1873. saleOrderEstimatedTime,
  1874. saleLeadTime,
  1875. deliveryDate,
  1876. saleAmounts,
  1877. saleAmountInWords,
  1878. salePayType,
  1879. salesman,
  1880. customAddress,
  1881. customCountryType, //国家类型
  1882. contactPerson, //联系人
  1883. // 工艺表数据
  1884. orderRemark: remark,
  1885. });
  1886. this.customChangeHandler(saleCustomNo);
  1887. this.productionTableData = saleProductsList.map((item) => {
  1888. let {
  1889. id,
  1890. saleProductNo,
  1891. productNo, //货品编号
  1892. productName, //货品名称
  1893. productNumber, //销售数量
  1894. productWeight, //销售重量kg
  1895. productUnitPrice, //单价
  1896. productAmounts, //金额
  1897. sliceType, //切片类型 初始为 切片
  1898. sliceTypeLabel,
  1899. colourNumberLabel,
  1900. colourNumber, //色号
  1901. remark, //备注
  1902. } = item;
  1903. let productType = this.allProductionOptions.find(
  1904. (i) => productNo == i.productNo
  1905. )?.productType;
  1906. return {
  1907. id,
  1908. saleProductNo,
  1909. productNo, //货品编号
  1910. productType, //类型
  1911. productName, //货品名称
  1912. productNumber, //销售数量
  1913. productWeight, //销售重量kg
  1914. productUnitPrice, //单价
  1915. productAmounts, //金额
  1916. sliceType, //切片类型 初始为 切片
  1917. sliceTypeLabel,
  1918. colourNumberLabel,
  1919. colourNumber, //色号
  1920. remark,
  1921. };
  1922. });
  1923. this.initTableValidate();
  1924. },
  1925. /** 修改按钮操作 */
  1926. async handleUpdate(row) {
  1927. console.log(row);
  1928. this.isEdit = true;
  1929. await this.getDropDownData();
  1930. this.isLeader = !this.userInfo.roles.includes("salesman");
  1931. if (!this.isLeader) {
  1932. this.createById = this.userInfo.userId;
  1933. }
  1934. await this.getRoleUser();
  1935. this.title = "修改零售单";
  1936. try {
  1937. let res = await getRetailOrderInfo(row.id);
  1938. console.log(res);
  1939. if (res.code == 200) {
  1940. this.initData(res.data);
  1941. this.open = true;
  1942. } else {
  1943. this.$message.error(res.msg);
  1944. }
  1945. } catch (error) {
  1946. console.log(error);
  1947. }
  1948. },
  1949. //详情 打印回调
  1950. async handlePrint(row) {
  1951. await this.getDropDownData();
  1952. this.isLeader = !this.userInfo.roles.includes("salesman");
  1953. if (!this.isLeader) {
  1954. this.createById = this.userInfo.userId;
  1955. }
  1956. await this.getRoleUser();
  1957. try {
  1958. let res = await getRetailOrderInfo(row.id);
  1959. console.log(res);
  1960. if (res.code == 200) {
  1961. this.initData(res.data);
  1962. this.printDomData = this.getPrintDom(res.data);
  1963. this.detailShow = true;
  1964. this.$nextTick(() => {
  1965. this.$refs.detailTable.innerHTML = this.printDomData;
  1966. });
  1967. } else {
  1968. this.$message.error(res.msg);
  1969. }
  1970. } catch (error) {
  1971. console.log(error);
  1972. }
  1973. },
  1974. // 提交 回调
  1975. async handleSubmit(row) {
  1976. this.deliverShow = true;
  1977. this.$nextTick(() => {
  1978. this.$refs.deliverRef.productInvoiceInfo(row);
  1979. });
  1980. },
  1981. // 取消提交
  1982. async handleSubmitCancel(row) {
  1983. console.log(row);
  1984. this.$confirm("此操作将撤回该次提交, 是否继续?", "提示", {
  1985. confirmButtonText: "确定",
  1986. cancelButtonText: "取消",
  1987. type: "warning",
  1988. })
  1989. .then(async () => {
  1990. // this.$message({
  1991. // type: 'success',
  1992. // message: '删除成功!'
  1993. // });
  1994. try {
  1995. let { saleNo } = row;
  1996. let payLoad = {
  1997. saleOrderNo: saleNo,
  1998. status: 1,
  1999. };
  2000. let res = await cancelRetailOrder(payLoad);
  2001. if (res.code == 200) {
  2002. this.$message.success("取消成功");
  2003. this.getList();
  2004. } else {
  2005. this.$message.error("取消失败");
  2006. console.log(res);
  2007. }
  2008. } catch (error) {
  2009. console.log(error);
  2010. }
  2011. })
  2012. .catch(() => {
  2013. this.$message({
  2014. type: "info",
  2015. message: "已取消",
  2016. });
  2017. });
  2018. },
  2019. // 获取打印dom
  2020. getPrintDom(data) {
  2021. let {
  2022. id,
  2023. //订单表数据
  2024. saleNo,
  2025. saleCustomNo,
  2026. saleDate,
  2027. saleOrderEstimatedTime,
  2028. saleLeadTime,
  2029. deliveryDate,
  2030. saleAmounts,
  2031. saleAmountInWords,
  2032. salePayType,
  2033. salesman,
  2034. customAddress,
  2035. customCountryType, //国家类型
  2036. contactPerson, //联系人
  2037. // 工艺表数据
  2038. orderRemark,
  2039. } = this.formData;
  2040. this.productionTableData;
  2041. let customData = this.customerOptions.find(
  2042. (item) => item.customNo == saleCustomNo
  2043. );
  2044. let customerName = customData ? customData.customName : "";
  2045. let printStr = `
  2046. <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  2047. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  2048. <div style="text-align:center;">销售合同审计单</div>
  2049. <tbody>
  2050. <tr>
  2051. <td width="600px" colspan="4">合同号:${saleNo}</td>
  2052. <td width="600px" colspan="4">日期:${saleDate.replace(
  2053. "T",
  2054. " "
  2055. )}</td>
  2056. </tr>
  2057. <tr align="center">
  2058. <td width="300px" colspan="2">客户名称:</td>
  2059. <td width="300px" colspan="2">${customerName}</td>
  2060. <td colspan="2">业务员:</td>
  2061. <td colspan="2">${salesman}</td>
  2062. </tr>
  2063. <tr align="center">
  2064. <td width="300px" colspan="2">客户地址:</td>
  2065. <td width="300px" colspan="2">${customAddress}</td>
  2066. <td width="300px" colspan="2">客户国别:</td>
  2067. <td width="300px" colspan="2">${customCountryType}</td>
  2068. </tr>
  2069. <tr align="center">
  2070. <td width="300px" colspan="2">联系人:</td>
  2071. <td width="150px" colspan="1">${contactPerson}</td>
  2072. <td colspan="2">合计金额(大写):</td>
  2073. <td colspan="3">${saleAmountInWords}</td>
  2074. </tr>
  2075. <tr align="center">
  2076. <td colspan="8">货品明细</td>
  2077. </tr>
  2078. <tr align="center">
  2079. <td width="150px">品名</td>
  2080. <td width="150px">类型</td>
  2081. <td width="150px">箱数</td>
  2082. <td width="150px">单价</td>
  2083. <td width="150px">金额</td>
  2084. <td width="150px">切片型号</td>
  2085. <td width="150px">色号</td>
  2086. <td width="150px">备注</td>
  2087. </tr>`;
  2088. let amountTotal = 0,
  2089. singlTotal = 0,
  2090. moneyTotal = 0;
  2091. for (let i = 0; i < this.productionTableData.length; i++) {
  2092. let item = this.productionTableData[i];
  2093. amountTotal += Number(item.productNumber);
  2094. singlTotal += Number(item.productUnitPrice);
  2095. moneyTotal += Number(item.productAmounts);
  2096. let productData = this.allProductionOptions.find(
  2097. (pro) => pro.productNo == item.productNo
  2098. );
  2099. item.sliceTypeLabel =
  2100. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  2101. ?.materielName || "";
  2102. item.colourNumberLabel = this.colourNumberOptions.find(
  2103. (k) => k.materielCode == item.colourNumber
  2104. )?.materieColorNumber;
  2105. let productName = productData ? productData.productName : "";
  2106. let productType = productData ? productData.productType : "";
  2107. printStr += `<tr align="center">
  2108. <td>${productName}</td>
  2109. <td>${productType}</td>
  2110. <td>${item.productNumber}</td>
  2111. <td>${item.productUnitPrice}</td>
  2112. <td>${item.productAmounts}</td>
  2113. <td>${item.sliceTypeLabel}</td>
  2114. <td>${item.colourNumberLabel}</td>
  2115. <td>${item.remark}</td>
  2116. </tr>`;
  2117. }
  2118. // 计算小计
  2119. amountTotal = amountTotal.toFixed(2);
  2120. singlTotal = singlTotal.toFixed(2);
  2121. moneyTotal = moneyTotal.toFixed(2);
  2122. printStr += `
  2123. <tr align="center">
  2124. <td>小计:</td>
  2125. <td></td>
  2126. <td>${amountTotal}</td>
  2127. <td>${singlTotal}</td>
  2128. <td>${moneyTotal}</td>
  2129. <td></td>
  2130. <td></td>
  2131. <td></td>
  2132. </tr>`;
  2133. printStr += `<tr align="left">
  2134. <td colspan="8">订单备注:${orderRemark}</td>
  2135. </tr>
  2136. </tbody>
  2137. </table>`;
  2138. return printStr;
  2139. },
  2140. // 添加真正的字段名
  2141. addRealFieldName(row) {
  2142. let fieldList = Object.keys(row);
  2143. // let tableName = this.longestCommonSubstring(fieldList);
  2144. let tableName = camelCase(this.tableName);
  2145. fieldList.forEach((field) => {
  2146. let realField = field.replace(tableName, "");
  2147. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  2148. row[realField] = row[field];
  2149. });
  2150. },
  2151. /** 提交按钮 */
  2152. submitForm: function () {
  2153. this.$refs["form"].validate((valid) => {
  2154. if (valid) {
  2155. if (this.form.userId != undefined) {
  2156. updateUser(this.form).then((response) => {
  2157. this.$modal.msgSuccess("修改成功");
  2158. this.open = false;
  2159. this.getList();
  2160. });
  2161. } else {
  2162. addUser(this.form).then((response) => {
  2163. this.$modal.msgSuccess("新增成功");
  2164. this.open = false;
  2165. this.getList();
  2166. });
  2167. }
  2168. }
  2169. });
  2170. },
  2171. /** 删除按钮操作
  2172. *
  2173. * 删除提示信息语句(标识)
  2174. * */
  2175. handleDelete(row, btnData) {
  2176. let delIds = this.ids;
  2177. let primary = camelCase(this.templateInfo.template?.primaryKey);
  2178. // let realyKey=
  2179. this.addRealFieldName(row);
  2180. if (row[primary] != undefined && row[primary] != null) {
  2181. delIds = [];
  2182. delIds.push(row[primary]);
  2183. }
  2184. let data = {
  2185. basicMap: {
  2186. btnType: btnData.btnType,
  2187. btnKey: btnData.btnKey,
  2188. tableName: this.tableName,
  2189. },
  2190. conditionMap: {
  2191. // id: delIds,
  2192. },
  2193. btnParametersMap: {},
  2194. };
  2195. if (this.currentBtnData.btnParams) {
  2196. let btnParams =
  2197. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2198. let conditionData =
  2199. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2200. conditionData.forEach((item) => {
  2201. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2202. ? item.fieldValue
  2203. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2204. });
  2205. btnParams.forEach((item) => {
  2206. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  2207. ? item.fieldValue
  2208. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2209. });
  2210. }
  2211. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  2212. this.$modal
  2213. .confirm('是否确认删除"' + delIds + '"的数据项?')
  2214. .then(function () {
  2215. // return delTableData(data);
  2216. return btnCommonApi(data);
  2217. })
  2218. .then(() => {
  2219. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2220. this.$refs.mychild.pageList();
  2221. this.$modal.msgSuccess("删除成功");
  2222. })
  2223. .catch(() => {});
  2224. },
  2225. // 批量删除接口
  2226. handleBatchDelete() {
  2227. let delIds = this.ids;
  2228. let primary = camelCase(this.templateInfo.template?.primaryKey);
  2229. // if (row && row[primary] != undefined && row[primary] != null) {
  2230. // delIds = [];
  2231. // delIds.push(row[primary]);
  2232. // }
  2233. let data = {
  2234. basicMap: {
  2235. tableName: this.tableName,
  2236. },
  2237. conditionMap: {
  2238. // id: delIds,
  2239. },
  2240. };
  2241. // if (this.currentBtnData.btnParams) {
  2242. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  2243. // btnParams.forEach((item) => {
  2244. // data.btnParametersMap[
  2245. // this.formatField(item.fieldName, camelCase(this.tableName))
  2246. // ] = item.fieldValue
  2247. // ? item.fieldValue
  2248. // : this.currentRow[item.fieldName];
  2249. // });
  2250. // }
  2251. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  2252. this.$modal
  2253. .confirm('是否确认删除"' + delIds + '"的数据项?')
  2254. .then(function () {
  2255. return delTableData(data);
  2256. // return btnCommonApi(data);
  2257. })
  2258. .then(() => {
  2259. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2260. this.$refs.mychild.pageList();
  2261. this.$modal.msgSuccess("删除成功");
  2262. })
  2263. .catch(() => {});
  2264. },
  2265. /** 导出按钮操作 */
  2266. handleExport() {
  2267. let primary = "saleOrderId";
  2268. let realyKey = "saleOrderId";
  2269. if (this.myDelIds.length > 0) {
  2270. this.queryParams["execlMap"] = [];
  2271. this.myDelIds.forEach((item) => {
  2272. this.queryParams.execlMap.push(
  2273. this.tableList.find((ttem) => {
  2274. return ttem[realyKey] === item;
  2275. })
  2276. );
  2277. });
  2278. } else {
  2279. this.$message.warning("请至少勾选一条导出数据");
  2280. return;
  2281. }
  2282. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  2283. this.download(
  2284. process.env.VUE_APP_BASE_API1 + "common/export",
  2285. {
  2286. ...this.queryParams,
  2287. },
  2288. `文件名称_${new Date().getTime()}.xlsx`
  2289. );
  2290. },
  2291. /** 导入按钮操作 */
  2292. handleImport() {
  2293. this.upload.title = "当前导入";
  2294. this.upload.open = true;
  2295. },
  2296. /** 下载模板操作 */
  2297. importTemplate() {
  2298. this.download(
  2299. process.env.VUE_APP_BASE_API1 +
  2300. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  2301. {},
  2302. `下载模版名称${new Date().getTime()}.xlsx`
  2303. );
  2304. },
  2305. // 文件上传中处理
  2306. handleFileUploadProgress(event, file, fileList) {
  2307. this.upload.isUploading = true;
  2308. },
  2309. // 文件上传成功处理
  2310. handleFileSuccess(response, file, fileList) {
  2311. this.upload.open = false;
  2312. this.upload.isUploading = false;
  2313. this.$refs.upload.clearFiles();
  2314. this.$alert(
  2315. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  2316. response.msg +
  2317. "</div>",
  2318. "导入结果",
  2319. { dangerouslyUseHTMLString: true }
  2320. );
  2321. this.$refs.mychild.pageList({
  2322. limit: this.queryParams.pageSize,
  2323. page: this.queryParams.pageNum,
  2324. });
  2325. },
  2326. //重点在这里
  2327. handleChange(file, fileList) {
  2328. file.name = this.tableName + "." + file.name.split(".")[1];
  2329. fileList.forEach((item) => {
  2330. item.name = this.tableName + "." + file.name.split(".")[1];
  2331. });
  2332. let newFile = new File(
  2333. [file],
  2334. this.tableName + "." + file.name.split(".")[1]
  2335. ); //创建出来也是不可编辑的file对象
  2336. },
  2337. // 提交上传文件
  2338. submitFileForm() {
  2339. this.$refs.upload.submit();
  2340. },
  2341. // 弹窗新增的数
  2342. addListHandler(val) {
  2343. this.addLists.push(...val);
  2344. },
  2345. // 绑定弹窗Dialog确定按钮
  2346. async btnComfirm() {
  2347. let res = await this.$refs.deliverRef.getAllData();
  2348. let { flag, isEdit, data } = res;
  2349. if (flag) {
  2350. // if (isEdit) {
  2351. // //编辑
  2352. // let payLoad = {
  2353. // ...data.formData,
  2354. // saleProductInfoList: data.tableData,
  2355. // };
  2356. // let res = await updateProductInvoice(payLoad);
  2357. // if (res.code == 200) {
  2358. // this.$message.success("修改成功");
  2359. // this.deliverShow = false;
  2360. // this.getList();
  2361. // } else {
  2362. // this.$message.error("网络异常");
  2363. // }
  2364. // } else {
  2365. //新增
  2366. let payLoad = {
  2367. ...data.formData,
  2368. saleProductInfoList: data.tableData,
  2369. };
  2370. payLoad.status = 5;
  2371. // let res = await addProductInvoice(payLoad);
  2372. let res = await submitRetailOrder(payLoad);
  2373. if (res.code == 200) {
  2374. this.$message.success("提交成功");
  2375. this.deliverShow = false;
  2376. this.getList();
  2377. } else {
  2378. this.$message.error("网络异常");
  2379. }
  2380. // }
  2381. }
  2382. },
  2383. // 保存提交数据
  2384. async btnSave() {
  2385. let res = await this.$refs.deliverRef.getAllData();
  2386. let { flag, isEdit, data } = res;
  2387. if (flag) {
  2388. let payLoad = {
  2389. ...data.formData,
  2390. saleProductInfoList: data.tableData,
  2391. };
  2392. payLoad.status = 1;
  2393. let res = await updateProductInvoice(payLoad);
  2394. if (res.code == 200) {
  2395. this.$message.success("保存成功");
  2396. this.deliverShow = false;
  2397. this.getList();
  2398. } else {
  2399. this.$message.error("网络异常");
  2400. }
  2401. // }
  2402. }
  2403. },
  2404. // 去掉表名 开头字母小写
  2405. formatField(field = "", tableName) {
  2406. let temp = field.replace(tableName, "");
  2407. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  2408. },
  2409. //提交编辑结果按钮回调
  2410. async editConfirmHandler() {
  2411. if (this.$refs.addFromRef) {
  2412. this.$refs.addFromRef
  2413. .getData()
  2414. .then(async (values) => {
  2415. let data = {
  2416. basicMap: {
  2417. tableName: this.tableName,
  2418. // btnKey: btnData.btnKey,
  2419. btnKey: this.currentBtnData.btnKey,
  2420. },
  2421. addListMap: [values],
  2422. conditionMap: {},
  2423. commMap: {},
  2424. btnParametersMap: {},
  2425. };
  2426. if (this.currentBtnData.btnParams) {
  2427. let btnParams =
  2428. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  2429. [];
  2430. let conditionData =
  2431. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2432. // let
  2433. btnParams.forEach((item) => {
  2434. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2435. item.fieldValue
  2436. ? item.fieldValue
  2437. : this.currentRow[
  2438. camelCase(item.fieldName.replace(".", "_"))
  2439. ];
  2440. });
  2441. conditionData.forEach((item) => {
  2442. data.conditionMap[item.fieldName.split(".")[1]] =
  2443. item.fieldValue
  2444. ? item.fieldValue
  2445. : this.currentRow[
  2446. camelCase(item.fieldName.replace(".", "_"))
  2447. ];
  2448. });
  2449. }
  2450. if (Object.keys(this.defaultValue).length) {
  2451. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  2452. // this.defaultValue[this.templateInfo.template?.primaryKey];
  2453. Object.keys(values).map((k) => {
  2454. data.commMap[k] = values[k];
  2455. });
  2456. data.basicMap.btnType = this.currentBtnData.btnType;
  2457. data.basicMap.visible = true;
  2458. } else {
  2459. data.basicMap.btnType = "INSERT";
  2460. data.basicMap.visible = true;
  2461. }
  2462. try {
  2463. let res = await btnCommonApi(data);
  2464. if (res.code == 200) {
  2465. this.$message.success("操作成功");
  2466. } else {
  2467. this.$message.error("网络异常,请稍后再试");
  2468. }
  2469. } catch (error) {
  2470. console.log(error);
  2471. this.$message.error("网络异常,请稍后再试");
  2472. }
  2473. this.getList();
  2474. this.defaultValue = {};
  2475. this.kOpen = false;
  2476. })
  2477. .catch((res) => {
  2478. console.log(res);
  2479. this.$modal.msgError("表单校验失败,请规范填写数据");
  2480. });
  2481. } else {
  2482. // 没有绑定表单
  2483. let data = {
  2484. basicMap: {
  2485. tableName: this.tableName,
  2486. // btnKey: btnData.btnKey,
  2487. btnKey: this.currentBtnData.btnKey,
  2488. btnType: this.currentBtnData.btnType,
  2489. visible: true,
  2490. },
  2491. addListMap: [],
  2492. conditionMap: {},
  2493. commMap: {},
  2494. btnParametersMap: {},
  2495. };
  2496. if (this.currentBtnData.btnParams) {
  2497. let btnParams =
  2498. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2499. let conditionData =
  2500. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2501. conditionData.forEach((item) => {
  2502. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2503. ? item.fieldValue
  2504. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2505. });
  2506. btnParams.forEach((item) => {
  2507. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2508. item.fieldValue
  2509. ? item.fieldValue
  2510. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2511. });
  2512. }
  2513. // data.basicMap.btnType = this.currentBtnData.btnType;
  2514. // data.basicMap.visible = true;
  2515. try {
  2516. let res = await btnCommonApi(data);
  2517. if (res.code == 200) {
  2518. this.$message.success("操作成功");
  2519. } else {
  2520. this.$message.error("网络异常,请稍后再试");
  2521. }
  2522. } catch (error) {
  2523. console.log(error);
  2524. this.$message.error("网络异常,请稍后再试");
  2525. }
  2526. this.getList();
  2527. this.defaultValue = {};
  2528. this.kOpen = false;
  2529. }
  2530. },
  2531. // 使用提交数据类型的按钮获取数据
  2532. tempSubBtn(getData) {
  2533. getData()
  2534. .then((values) => {
  2535. console.log("验证通过", values);
  2536. })
  2537. .catch(() => {
  2538. console.log("验证未通过,获取失败");
  2539. });
  2540. },
  2541. // 判断是否生效行样式
  2542. cellStyle({ row, column, rowIndex, columnIndex }) {
  2543. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  2544. if (!rowStyleList.length) return "";
  2545. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  2546. for (let i = 0; i < rowStyleList.length; i++) {
  2547. let item = rowStyleList[i];
  2548. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2549. if (judgeRes) {
  2550. let styleCode = JSON.parse(item.styleCode);
  2551. return `background-color:${styleCode.rowBgColor};`;
  2552. }
  2553. }
  2554. },
  2555. // 获取生效条件组结果
  2556. determineCondition(conditionStr, row) {
  2557. let conditionList = JSON.parse(conditionStr);
  2558. if (!conditionList.length) return false;
  2559. return conditionList.every((item) => this.judgeOneCondition(item, row));
  2560. },
  2561. // 获取单个判断条件结果
  2562. judgeOneCondition(item, row) {
  2563. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  2564. switch (item.condition) {
  2565. case 1:
  2566. return row[fullField] > item.flagValue;
  2567. case 2:
  2568. return row[fullField] < item.flagValue;
  2569. case 3:
  2570. return row[fullField] == item.flagValue;
  2571. case 4:
  2572. return row[fullField] >= item.flagValue;
  2573. case 5:
  2574. return row[fullField] <= item.flagValue;
  2575. default:
  2576. return true; //默认为true
  2577. }
  2578. },
  2579. // 设置表格字段样式
  2580. async setFieldStyleData(tableList) {
  2581. console.log(JSON.parse(JSON.stringify(tableList)));
  2582. let fieldConditionList = this.styleList.filter(
  2583. (item) => item.styleType == 1 || item.styleType == 2
  2584. );
  2585. if (!fieldConditionList.length) return tableList;
  2586. let res = await this.setDictStyleData();
  2587. this.dictStyleObj = res.reduce((pre, item) => {
  2588. return {
  2589. ...pre,
  2590. ...item,
  2591. };
  2592. }, {});
  2593. // console.log("this.dictStyleObj", this.dictStyleObj);
  2594. tableList.forEach((row) => {
  2595. // if (!row.styleFieldObj) row.styleFieldObj = {};
  2596. for (let i = 0; i < fieldConditionList.length; i++) {
  2597. let item = fieldConditionList[i];
  2598. if (item.styleType == 1) {
  2599. //字段样式
  2600. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2601. if (judgeRes) {
  2602. let styleCode = JSON.parse(item.styleCode);
  2603. if (!row.styleFieldObj) row.styleFieldObj = {};
  2604. row.styleFieldObj[item.styleField] = {
  2605. styleType: item.styleType,
  2606. fieldStyleType: styleCode.fieldStyleType,
  2607. fontColor: styleCode.fontColor,
  2608. isTagFullBg: styleCode.isTagFullBg,
  2609. tagType: styleCode.tagType,
  2610. };
  2611. // row.styleField = item.styleField; //样式生效字段
  2612. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  2613. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  2614. // row.fontColor = styleCode.fontColor;
  2615. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  2616. // row.tagType = styleCode.tagType; //string
  2617. }
  2618. } else {
  2619. //字典样式
  2620. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  2621. return dict.dictValue == row[item.styleField];
  2622. });
  2623. if (dicStyle) {
  2624. if (!row.styleFieldObj) row.styleFieldObj = {};
  2625. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  2626. row.styleFieldObj[item.styleField].styleType = 2;
  2627. }
  2628. }
  2629. }
  2630. });
  2631. return tableList;
  2632. },
  2633. //设置表格字典相关数据
  2634. setDictStyleData() {
  2635. let fieldConditionList = this.styleList.filter(
  2636. (item) => item.styleType == 2
  2637. );
  2638. if (!fieldConditionList.length) return;
  2639. let PromiseList = fieldConditionList.map((item) => {
  2640. return new Promise((resolve, reject) => {
  2641. let temp = {};
  2642. try {
  2643. listData({
  2644. isEnablePaging: false,
  2645. dictType: item.styleCondtion,
  2646. }).then((res) => {
  2647. temp[item.styleField] = res.rows;
  2648. resolve(temp);
  2649. });
  2650. } catch (error) {
  2651. reject(error);
  2652. }
  2653. });
  2654. });
  2655. return Promise.all(PromiseList);
  2656. },
  2657. // 内链页面跳转
  2658. routerHandler(btnData, type) {
  2659. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  2660. let tempArr = [];
  2661. if (commonFieldData) {
  2662. let queryArr = JSON.parse(commonFieldData);
  2663. tempArr = queryArr.map((item) => {
  2664. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  2665. let value = item.fieldValue
  2666. ? item.fieldValue
  2667. : this.currentRow[item.fieldName];
  2668. return key + "=" + value;
  2669. });
  2670. }
  2671. if (tempArr.length) {
  2672. url += "?" + tempArr.join("&");
  2673. }
  2674. // let link = btnData.btnParams;
  2675. if (type == "INNERLINK") {
  2676. this.$router.push(url);
  2677. } else {
  2678. window.open("http://" + url, "_blank");
  2679. }
  2680. },
  2681. async handleDetail(row) {
  2682. this.printDomData = await this.getDetailTableString(row);
  2683. this.detailShow = true;
  2684. this.$nextTick(() => {
  2685. this.$refs.detailTable.innerHTML = this.printDomData;
  2686. });
  2687. },
  2688. // 切片类型改变回调
  2689. sliceTypeChangeHandler(row) {
  2690. let { sliceType } = row;
  2691. if (sliceType) {
  2692. row.sliceTypeLabel = this.sliceTypeOptions.find(
  2693. (item) => item.materielCode == sliceType
  2694. )?.materielName;
  2695. }
  2696. },
  2697. // 色号改变回调
  2698. colourNumberChangeHandler(row) {
  2699. let { colourNumber } = row;
  2700. if (colourNumber) {
  2701. let target = this.colourNumberOptions.find(
  2702. (item) => item.materielCode == colourNumber
  2703. );
  2704. if (target) {
  2705. row.colourNumberLabel =
  2706. target.materieEncoding + target.materieColorNumber;
  2707. }
  2708. // row.colourNumberLabel = this.colourNumberOptions.find(
  2709. // (item) => item.materielCode == colourNumber
  2710. // )?.materieColorNumber;
  2711. }
  2712. },
  2713. // 打印回调
  2714. detailPrintHandler() {
  2715. document.body.innerHTML = document.getElementById("printDom").innerHTML =
  2716. this.printDomData;
  2717. window.print(); //打印
  2718. window.location.reload();
  2719. return false;
  2720. },
  2721. // 根据字典value获取字典label
  2722. getDictLabel(value, dict) {
  2723. return (
  2724. this.dict.type[dict].find((item) => {
  2725. return item.value === value;
  2726. })?.label || ""
  2727. );
  2728. },
  2729. // 获取详情html字符串
  2730. async getDetailTableString(row) {
  2731. let { saleOrderSaleNo } = row;
  2732. let payLoad = [
  2733. {
  2734. basicMap: {
  2735. tableName: "sale_order",
  2736. },
  2737. conditionMap: {
  2738. sale_no: [saleOrderSaleNo],
  2739. },
  2740. },
  2741. {
  2742. basicMap: {
  2743. tableName: "sale_products",
  2744. },
  2745. conditionMap: {
  2746. sale_order_no: [saleOrderSaleNo],
  2747. },
  2748. },
  2749. {
  2750. basicMap: {
  2751. tableName: "sale_craft",
  2752. },
  2753. conditionMap: {
  2754. sale_order_no: [saleOrderSaleNo],
  2755. },
  2756. },
  2757. ];
  2758. let res = await queryDropDownBoxData(payLoad);
  2759. if (res.code == 200) {
  2760. console.log(res);
  2761. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  2762. let {
  2763. //订单表数据
  2764. saleNo, //合同号
  2765. lotNumber, //批号
  2766. saleCustomNo, //客户编号
  2767. saleDate, //销售单日期
  2768. saleOrderEstimatedTime, //预计下单时间
  2769. saleLeadTime, //交货周期
  2770. deliveryDate,
  2771. saleAmounts, //合计金额 小写
  2772. saleAmountInWords, //合计金额 大写
  2773. salePayType, //支付方式
  2774. earnestMoney,
  2775. salesman, //业务员
  2776. saleLeader, //业务主管
  2777. finance, //财务部
  2778. production, //生产部
  2779. saleApprover, //批准人
  2780. // customAddress, //客户地址
  2781. // customCountryType, //国家类型
  2782. // contactPerson, //联系人
  2783. // 货品明细表数据
  2784. // productNo, //货品号
  2785. // productName, //货品名称
  2786. // productNumber: "", //销售数量
  2787. // productWeight: "", //销售重量kg
  2788. // productUnitPrice: "", //单价
  2789. // productAmounts: "", //金额
  2790. // remark: "", //备注
  2791. // 工艺表
  2792. craftGrid, //网络
  2793. craftOil, //油剂
  2794. craftPackage, //卷装
  2795. craftColorFastness, //色牢度
  2796. directionOfTwist,
  2797. craftOther, //其它工艺要求
  2798. craftMark, //包装/贴唛
  2799. shippingMethod, //运输方式
  2800. } = { ...sale_craft[0], ...sale_order[0] };
  2801. let customData = this.customerOptions.find(
  2802. (item) => item.customNo == saleCustomNo
  2803. );
  2804. let payType = this.getDictLabel(salePayType, "payment_method"); //付款方式
  2805. let customerName = customData ? customData.customName : "";
  2806. let customAddress = customData?.customAddress || "无";
  2807. let customCountryType = customData?.customCountryType || "";
  2808. let contactPerson = customData?.contactPerson || "无";
  2809. let directionOfTwistDescription = directionOfTwist
  2810. ? this.getDictLabel(directionOfTwist, "direction_of_twist")
  2811. : "";
  2812. let printStr = `
  2813. <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  2814. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  2815. <div style="text-align:center;">销售合同审计单</div>
  2816. <tbody>
  2817. <tr>
  2818. <td width="600px" colspan="4">合同号:${saleNo}</td>
  2819. <td width="600px" colspan="4">日期:${saleDate.replace(
  2820. "T",
  2821. " "
  2822. )}</td>
  2823. </tr>
  2824. <tr align="center">
  2825. <td width="300px" colspan="2">客户名称:</td>
  2826. <td width="300px" colspan="2">${customerName}</td>
  2827. <td width="300px" colspan="2">联系人:</td>
  2828. <td width="150px" colspan="1">${contactPerson}</td>
  2829. </tr>
  2830. <tr align="center">
  2831. <td width="300px" colspan="2">客户地址:</td>
  2832. <td width="300px" colspan="2">${customAddress}</td>
  2833. <td width="300px" colspan="2">客户国别:</td>
  2834. <td width="300px" colspan="2">${customCountryType}</td>
  2835. </tr>
  2836. <tr align="center">
  2837. <td width="300px" colspan="2">预计下单时间:</td>
  2838. <td colspan="1">${saleOrderEstimatedTime.replace(
  2839. "T",
  2840. " "
  2841. )}</td>
  2842. <td colspan="1">交货周期:</td>
  2843. <td >${saleLeadTime}</td>
  2844. <td colspan="2">交货日期:</td>
  2845. <td >${deliveryDate.replace("T", " ")}</td>
  2846. </tr>
  2847. <tr align="center">
  2848. <td colspan="8">货品明细</td>
  2849. </tr>
  2850. <tr align="center">
  2851. <td width="150px">品名</td>
  2852. <td width="150px">类型</td>
  2853. <td width="150px">箱数</td>
  2854. <td width="150px">单价</td>
  2855. <td width="150px">金额</td>
  2856. <td width="150px">切片型号</td>
  2857. <td width="150px">色号</td>
  2858. <td width="150px">备注</td>
  2859. </tr>`;
  2860. let amountTotal = 0,
  2861. singlTotal = 0,
  2862. moneyTotal = 0;
  2863. for (let i = 0; i < sale_products.length; i++) {
  2864. let item = sale_products[i];
  2865. amountTotal += Number(item.productNumber);
  2866. singlTotal += Number(item.productUnitPrice);
  2867. moneyTotal += Number(item.productAmounts);
  2868. let productData = this.productionOptions.find(
  2869. (pro) => pro.productNo == item.productNo
  2870. );
  2871. console.log("item", item);
  2872. item.sliceTypeLabel =
  2873. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  2874. ?.materielName || "";
  2875. item.colourNumberLabel = this.colourNumberOptions.find(
  2876. (k) => k.materielCode == item.colourNumber
  2877. )?.materieColorNumber;
  2878. let productName = productData ? productData.productName : "";
  2879. let productType = productData ? productData.productType : "";
  2880. printStr += `<tr align="center">
  2881. <td>${productName}</td>
  2882. <td>${productType}</td>
  2883. <td>${item.productNumber}</td>
  2884. <td>${item.productUnitPrice}</td>
  2885. <td>${item.productAmounts}</td>
  2886. <td>${item.sliceTypeLabel}</td>
  2887. <td>${item.colourNumberLabel}</td>
  2888. <td>${item.remark}</td>
  2889. </tr>`;
  2890. }
  2891. // 计算小计
  2892. printStr += `
  2893. <tr align="center">
  2894. <td>小计:</td>
  2895. <td></td>
  2896. <td>${amountTotal}</td>
  2897. <td>${singlTotal}</td>
  2898. <td>${moneyTotal}</td>
  2899. <td></td>
  2900. <td></td>
  2901. <td></td>
  2902. </tr>
  2903. <tr>
  2904. <td colspan="8">合计金额(大写):${saleAmountInWords}</td>
  2905. </tr>
  2906. `;
  2907. if (salePayType == "1") {
  2908. //定金
  2909. printStr += `
  2910. <tr>
  2911. <td colspan="4">付款方式:${payType}</td>
  2912. <td colspan="4">定金:${earnestMoney}</td>
  2913. </tr>`;
  2914. } else {
  2915. printStr += `
  2916. <tr>
  2917. <td colspan="8">付款方式:${payType}</td>
  2918. </tr>`;
  2919. }
  2920. printStr += `<tr align="center">
  2921. <td colspan="8">工艺要求</td>
  2922. </tr>
  2923. <tr align="center">
  2924. <td width="150px">网络</td>
  2925. <td width="150px">油剂</td>
  2926. <td width="150px">卷装</td>
  2927. <td width="150px">色牢度</td>
  2928. <td width="150px">捻向</td>
  2929. <td width="150px">其他</td>
  2930. <td width="150px"></td>
  2931. <td width="150px"></td>
  2932. </tr>
  2933. <tr align="center">
  2934. <td >${craftGrid}</td>
  2935. <td>${craftOil}</td>
  2936. <td>${craftPackage}</td>
  2937. <td>${craftColorFastness}</td>
  2938. <td>${directionOfTwistDescription}</td>
  2939. <td>${craftOther}</td>
  2940. <td width="150px"></td>
  2941. <td width="150px"></td>
  2942. </tr>
  2943. <tr>
  2944. <td colspan="8">包装/贴唛:${craftMark}</td>
  2945. </tr>
  2946. <tr>
  2947. <td colspan="8">装运方式:${shippingMethod}</td>
  2948. </tr>
  2949. <tr align="center">
  2950. <td colspan="2">业务员:</td>
  2951. <td colspan="2">${salesman}</td>
  2952. <td colspan="2">财务部:</td>
  2953. <td colspan="2">${finance}</td>
  2954. </tr>
  2955. <tr align="center">
  2956. <td colspan="2">业务主管:</td>
  2957. <td colspan="2">${saleApprover}</td>
  2958. <td></td>
  2959. <td></td>
  2960. <td></td>
  2961. <td></td>
  2962. </tr>
  2963. </tbody>
  2964. </table>
  2965. `;
  2966. return printStr;
  2967. // <td colspan="2">业务主管:</td>
  2968. // <td colspan="2">${saleLeader}</td>
  2969. // <tr align="center">
  2970. // // <td colspan="2">生产部:</td>
  2971. // // <td colspan="2">${production}</td>
  2972. // </tr>
  2973. // <tr align="center">
  2974. // <td colspan="2"> 2</td>
  2975. // <td> </td>
  2976. // <td> </td>
  2977. // <td> </td>
  2978. // <td> </td>
  2979. // </tr>
  2980. // <tr>
  2981. // <td colspan="2">小计:</td>
  2982. // <td></td>
  2983. // <td></td>
  2984. // <td></td>
  2985. // <td></td>
  2986. // </tr>
  2987. }
  2988. },
  2989. // 自定义删除按钮
  2990. async myDeleteHandler(row) {
  2991. console.log(row);
  2992. let stateArr = ["2", "3", "4", "5", "6", "8"];
  2993. let isDeleteValidate = this.selection.some((item) => {
  2994. return stateArr.includes(item.status);
  2995. });
  2996. console.log(this.selection);
  2997. console.log(isDeleteValidate);
  2998. if (isDeleteValidate) {
  2999. this.$message.error("仅允许删除订单状态为'未提交'或'未通过'的订单");
  3000. return;
  3001. }
  3002. await this.$confirm("是否确认删除选中的数据?", "警告", {
  3003. confirmButtonText: "确定",
  3004. cancelButtonText: "取消",
  3005. type: "warning",
  3006. });
  3007. let payLoad = row.saleOrderId ? [row.saleOrderId] : this.myDelIds;
  3008. console.log(payLoad);
  3009. try {
  3010. let res = await delOrder(payLoad);
  3011. if (res.code === 200) {
  3012. this.$message.success("删除成功");
  3013. this.getList();
  3014. this.myDelIds = [];
  3015. // this.$nextTick(() => {
  3016. // this.$refs.tableRef?.clearSelection();
  3017. // });
  3018. } else {
  3019. this.$message.error(res.msg);
  3020. }
  3021. } catch (error) {}
  3022. },
  3023. // 发货回调
  3024. myDeliverHandler(row) {
  3025. this.currentRow = row;
  3026. this.deliverShow = true;
  3027. this.$nextTick(() => {
  3028. this.$refs.deliverRef.productInvoiceInfo(row);
  3029. });
  3030. },
  3031. },
  3032. };
  3033. </script>
  3034. <style scoped lang="scss">
  3035. ::v-deep .el-dialog:not(.is-fullscreen) {
  3036. min-width: 610px !important;
  3037. }
  3038. </style>