approve.vue 95 KB

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