approve.vue 94 KB

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