224141144689b9ad5d78fbd043f812946c5a0978.svn-base 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <div class="recipeTemplate">
  6. <p>配方模板表</p>
  7. </div>
  8. <div class="operation">
  9. <el-button class="success" @click="handleCreate">新增</el-button>
  10. <el-button class="danger" @click="handleDelete">删除</el-button>
  11. <el-button class="warning" @click="handleCopy">复制</el-button>
  12. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  13. <!-- <el-button class="success" @click="handleHistory">生成历史</el-button> -->
  14. <el-upload style="float: right;margin-right: 75px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  15. <el-button class="import" style="float: right;">导入</el-button>
  16. </el-upload>
  17. <el-dropdown style="float: right;margin-right: 10px;">
  18. <el-button class="export">导出</el-button>
  19. <el-dropdown-menu slot="dropdown">
  20. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  21. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. </div>
  25. <div class="search">
  26. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  27. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  28. </el-select>
  29. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  30. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  31. </el-select>
  32. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  33. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  34. </el-select>
  35. <div ref="selectInput" class="filter-item selectInput">
  36. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  37. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  38. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  39. <ul v-if="arrowUp" class="selectUl">
  40. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  41. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  42. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  43. <li>
  44. <div style="float: right;">
  45. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  46. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  47. </div>
  48. </li>
  49. </ul>
  50. </div>
  51. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  52. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  53. </div>
  54. <div class="table">
  55. <el-table
  56. :key="table.tableKey"
  57. v-loading="table.listLoading"
  58. element-loading-text="给我一点时间"
  59. :data="table.list"
  60. border
  61. fit
  62. highlight-current-row
  63. style="width: 98%;"
  64. :row-style="rowStyle"
  65. :cell-style="cellStyle"
  66. :height="350"
  67. class="elTable table-fixed"
  68. @row-click="tableRowClick"
  69. @selection-change="handleSelectionChange"
  70. >
  71. <el-table-column type="selection" align="center" width="50" />
  72. <el-table-column label="序号" align="center" type="index" width="50px">
  73. <template slot-scope="scope">
  74. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="配方名称" min-width="110px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  80. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="配方颜色" min-width="85px" align="center">
  84. <template slot-scope="scope">
  85. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="牲畜类别" min-width="130px" align="center">
  89. <template slot-scope="scope">
  90. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  91. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  92. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="配方类型" min-width="130px" align="center">
  97. <template slot-scope="scope">
  98. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  99. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  100. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  101. </el-select>
  102. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  103. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  104. </el-select>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="来源" min-width="90px" align="center">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.source }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="备注" min-width="90px" align="center">
  113. <template slot-scope="scope">
  114. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  115. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="版本号" min-width="90px" align="center">
  119. <template slot-scope="scope">
  120. <span>{{ scope.row.version }}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="是否启用" min-width="90px" align="center">
  124. <template slot-scope="scope">
  125. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  129. <template slot-scope="{row}">
  130. <!-- 新增 -->
  131. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  132. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  133. <!-- 编辑 -->
  134. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  135. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  136. <!-- 编辑保存 -->
  137. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  138. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  139. <el-button v-if="row.NoEdit && isFormula" class="miniSuccess" @click="handleFormulationEvaluation(row)">配方评估</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. </div>
  144. </div>
  145. <!-- 配方详情表 -->
  146. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  147. <div class="recipeTemplate">
  148. <p>配方详情表</p>
  149. </div>
  150. <div class="operation">
  151. <el-button style="float: left;" class="success" @click="handleCreate2">新增</el-button>
  152. <el-button style="float: left;" class="danger" @click="handleDelete2">删除</el-button>
  153. <el-button style="float: left;" class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  154. <el-button v-if="isOrder" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  155. <div v-else style="float: left;margin-left: 10px;">
  156. <el-button class="success" @click="saveChangeOrder">保存</el-button>
  157. <el-button class="success" @click="cancelChangeOrder">取消</el-button>
  158. </div>
  159. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  160. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  161. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  162. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  163. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  164. <li>
  165. <a style="width: 130px;">饲料名称</a>
  166. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  167. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  168. </el-select>
  169. </li>
  170. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  171. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  172. <li>
  173. <a style="width: 130px;">搅拌延时</a>
  174. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  175. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  176. </el-select>
  177. </li>
  178. <li>
  179. <a style="width: 130px;">是否锁定牛头数比例</a>
  180. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  181. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  182. </el-select>
  183. </li>
  184. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  185. <li>
  186. <div style="float: right;">
  187. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  188. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  189. </div>
  190. </li>
  191. </ul>
  192. </div>
  193. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  194. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  195. </div>
  196. <div class="table2" style="min-height: 400px;">
  197. <el-table
  198. id="table2"
  199. ref="table2"
  200. :key="table2.tableKey"
  201. v-loading="table2.listLoading"
  202. element-loading-text="给我一点时间"
  203. :data="table2.list"
  204. border
  205. fit
  206. highlight-current-row
  207. style="width: 98%;"
  208. :row-style="rowStyle"
  209. :cell-style="cellStyle"
  210. class="elTable table-fixed"
  211. row-key="id"
  212. :summary-method="getSummaries"
  213. show-summary
  214. @selection-change="handleSelectionChange2"
  215. >
  216. <el-table-column type="selection" width="60" />
  217. <el-table-column label="序号" align="center" type="index" width="50px" />
  218. <el-table-column label="饲料组" min-width="110px" align="center">
  219. <template slot-scope="scope">
  220. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  221. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  222. </template>
  223. </el-table-column>
  224. <el-table-column label="饲料名称" min-width="130px" align="center">
  225. <template slot-scope="scope">
  226. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  227. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  228. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  229. </el-select>
  230. </template>
  231. </el-table-column>
  232. <el-table-column label="重量(KG)" prop="fweight" min-width="180px" align="center">
  233. <template slot-scope="scope">
  234. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  235. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  236. </template>
  237. </el-table-column>
  238. <el-table-column label="搅拌延时(min)" min-width="90px" align="center">
  239. <template slot-scope="scope">
  240. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  241. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  242. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  243. </el-select>
  244. </template>
  245. </el-table-column>
  246. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  247. <template slot-scope="scope">
  248. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  249. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  250. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  251. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  252. </el-select>
  253. </template>
  254. </el-table-column>
  255. <el-table-column label="顺序" min-width="90px" align="center">
  256. <template slot-scope="scope">
  257. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  258. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  259. </template>
  260. </el-table-column>
  261. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  262. <template slot-scope="{row}">
  263. <!-- 新增 -->
  264. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  265. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  266. <!-- 编辑 -->
  267. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  268. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  269. <!-- 编辑保存 -->
  270. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  271. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  272. <!-- 拆分预混料 -->
  273. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  274. </template>
  275. </el-table-column>
  276. </el-table>
  277. </div>
  278. </div>
  279. <!-- 配方记录 -->
  280. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  281. <div class="dialogMinHeight" style="overflow-y: auto;margin-bottom: 30px;overflow-x: hidden;">
  282. <div ref="templateDialog" class="templateDialog">
  283. <div class="recipeTemplate">
  284. <p>配方模板表</p>
  285. </div>
  286. <div class="operation">
  287. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  288. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  289. </div>
  290. <div class="search">
  291. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  292. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  293. </el-select>
  294. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  295. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  296. </el-select>
  297. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  298. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  299. </el-select>
  300. <div ref="selectInput" class="filter-item selectInput">
  301. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  302. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  303. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  304. <ul v-if="arrowUp" class="selectUl">
  305. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  306. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  307. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  308. <li>
  309. <div style="float: right;">
  310. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  311. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  312. </div>
  313. </li>
  314. </ul>
  315. </div>
  316. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  317. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  318. </div>
  319. <div class="table">
  320. <el-table
  321. :key="template.table.tableKey"
  322. v-loading="template.table.listLoading"
  323. element-loading-text="给我一点时间"
  324. :data="template.table.list"
  325. border
  326. fit
  327. highlight-current-row
  328. style="width: 98%;"
  329. :row-style="rowStyle"
  330. :cell-style="cellStyle"
  331. class="elTable table-fixed"
  332. @row-click="tableRowClickDialog"
  333. >
  334. <el-table-column v-if="template.dialogStatus == 'RecipeRecord'" label="序号" align="center" type="index" width="50px" />
  335. <el-table-column v-else label="序号" align="center" type="index" width="50px">
  336. <template slot-scope="scope">
  337. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  338. </template>
  339. </el-table-column>
  340. <el-table-column label="配方名称" min-width="130px" align="center">
  341. <template slot-scope="scope">
  342. <span>{{ scope.row.tname }}</span>
  343. </template>
  344. </el-table-column>
  345. <el-table-column label="配方颜色" min-width="110px" align="center">
  346. <template slot-scope="scope">
  347. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  348. </template>
  349. </el-table-column>
  350. <el-table-column label="牲畜类别" min-width="110px" align="center">
  351. <template slot-scope="scope">
  352. <span>{{ scope.row.ccname }}</span>
  353. </template>
  354. </el-table-column>
  355. <el-table-column label="配方类型" min-width="110px" align="center">
  356. <template slot-scope="scope">
  357. <span>{{ scope.row.fttype }}</span>
  358. </template>
  359. </el-table-column>
  360. <el-table-column label="来源" min-width="90px" align="center">
  361. <template slot-scope="scope">
  362. <span>{{ scope.row.source }}</span>
  363. </template>
  364. </el-table-column>
  365. <el-table-column label="备注" min-width="90px" align="center">
  366. <template slot-scope="scope">
  367. <span>{{ scope.row.remark }}</span>
  368. </template>
  369. </el-table-column>
  370. <el-table-column label="版本号" min-width="90px" align="center">
  371. <template slot-scope="scope">
  372. <span>{{ scope.row.version }}</span>
  373. </template>
  374. </el-table-column>
  375. <el-table-column label="版本时间" min-width="90px" align="center">
  376. <template slot-scope="scope">
  377. <span>{{ scope.row.versiontime }}</span>
  378. </template>
  379. </el-table-column>
  380. <el-table-column label="是否启用" min-width="90px" align="center">
  381. <template slot-scope="scope">
  382. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  383. </template>
  384. </el-table-column>
  385. </el-table>
  386. </div>
  387. </div>
  388. <div v-if="isDetailDialog" id="detailDialog2" ref="detailDialog2" class="detailDialog" style="margin-top: 30px;">
  389. <div class="recipeTemplate">
  390. <p>配方详情表</p>
  391. </div>
  392. <div class="operation">
  393. <div ref="selectInput2" class="filter-item selectInput">
  394. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  395. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  396. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  397. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  398. <li>
  399. <a style="width: 130px;">饲料名称</a>
  400. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  401. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  402. </el-select>
  403. </li>
  404. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  405. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  406. <li>
  407. <a style="width: 130px;">搅拌延时</a>
  408. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  409. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  410. </el-select>
  411. </li>
  412. <li>
  413. <a style="width: 130px;">是否锁定牛头数比例</a>
  414. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  415. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  416. </el-select>
  417. </li>
  418. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  419. <li>
  420. <div style="float: right;">
  421. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  422. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  423. </div>
  424. </li>
  425. </ul>
  426. </div>
  427. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  428. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  429. </div>
  430. <div class="table2">
  431. <el-table
  432. id="templateTable2"
  433. :key="template.table2.tableKey"
  434. v-loading="template.table2.listLoading"
  435. element-loading-text="给我一点时间"
  436. :data="template.table2.list"
  437. border
  438. fit
  439. highlight-current-row
  440. style="width: 98%;"
  441. :summary-method="getTemplateTable2Summaries"
  442. show-summary
  443. :row-style="rowStyle"
  444. :cell-style="cellStyle"
  445. class="elTable table-fixed"
  446. row-key="id"
  447. >
  448. <el-table-column label="饲料组" min-width="130px" align="center">
  449. <template slot-scope="scope">
  450. <span>{{ scope.row.feedgroup }}</span>
  451. </template>
  452. </el-table-column>
  453. <el-table-column label="饲料名称" min-width="130px" align="center">
  454. <template slot-scope="scope">
  455. <span>{{ scope.row.fname }}</span>
  456. </template>
  457. </el-table-column>
  458. <el-table-column label="重量(KG)" prop="fweight" min-width="200px" align="center">
  459. <template slot-scope="scope">
  460. <span>{{ scope.row.fweight }}</span>
  461. </template>
  462. </el-table-column>
  463. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  464. <template slot-scope="scope">
  465. <span>{{ scope.row.autosecondname }}</span>
  466. </template>
  467. </el-table-column>
  468. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  469. <template slot-scope="scope">
  470. <span v-if="scope.row.islockcount == '0'">否</span>
  471. <span v-if="scope.row.islockcount == '1'">是</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column label="顺序" min-width="130px" align="center">
  475. <template slot-scope="scope">
  476. <span>{{ scope.row.sort }}</span>
  477. </template>
  478. </el-table-column>
  479. </el-table>
  480. </div>
  481. </div>
  482. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  483. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  484. </div>
  485. </div>
  486. </el-dialog>
  487. <!-- 合成预混料 -->
  488. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  489. <div class="detailDialog">
  490. <h2>饲料</h2>
  491. <div class="table1">
  492. <el-table
  493. :key="detail.tableKey"
  494. v-loading="detail.listLoading"
  495. element-loading-text="给我一点时间"
  496. :data="detail.list"
  497. fit
  498. highlight-current-row
  499. style="width: 100%;"
  500. :row-style="rowStyle"
  501. :cell-style="cellStyle"
  502. class="elTable table-fixed"
  503. show-summary
  504. >
  505. <el-table-column label="序号" align="center" type="index" width="50px" />
  506. <el-table-column label="饲料名称" min-width="130px" align="center">
  507. <template slot-scope="scope">
  508. <span>{{ scope.row.fname }}</span>
  509. </template>
  510. </el-table-column>
  511. <el-table-column prop="fweight" label="重量(KG)" />
  512. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  513. <template slot-scope="scope">
  514. <span>{{ scope.row.autosecond }}</span>
  515. </template>
  516. </el-table-column>
  517. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  518. <template slot-scope="scope">
  519. <span v-if="scope.row.islockcount == '0'">否</span>
  520. <span v-if="scope.row.islockcount == '1'">是</span>
  521. </template>
  522. </el-table-column>
  523. <el-table-column label="顺序" min-width="110px" align="center">
  524. <template slot-scope="scope">
  525. <span>{{ scope.row.sort }}</span>
  526. </template>
  527. </el-table-column>
  528. </el-table>
  529. </div>
  530. <h2>合成预混料</h2>
  531. <div class="table2" style="margin-bottom: 50px;">
  532. <el-table
  533. :key="detail.tableKey2"
  534. v-loading="detail.listLoading2"
  535. element-loading-text="给我一点时间"
  536. :data="detail.list2"
  537. border
  538. fit
  539. highlight-current-row
  540. style="width: 100%;"
  541. :row-style="rowStyle"
  542. :cell-style="cellStyle"
  543. class="elTable table-fixed"
  544. >
  545. <el-table-column label="配方名称" min-width="130px" align="center">
  546. <template slot-scope="scope">
  547. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  548. </template>
  549. </el-table-column>
  550. <el-table-column label="配方颜色11" min-width="130px" align="center">
  551. <template slot-scope="scope">
  552. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  553. </template>
  554. </el-table-column>
  555. <el-table-column label="牲畜类别" min-width="130px" align="center">
  556. <template slot-scope="scope">
  557. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  558. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  559. </el-select>
  560. </template>
  561. </el-table-column>
  562. <el-table-column label="配方类型" min-width="110px" align="center">
  563. <template slot-scope="scope">
  564. <span>{{ scope.row.fttype }}</span>
  565. </template>
  566. </el-table-column>
  567. <el-table-column label="来源" min-width="110px" align="center">
  568. <template slot-scope="scope">
  569. <span>{{ scope.row.source }}</span>
  570. </template>
  571. </el-table-column>
  572. <el-table-column label="备注" min-width="130px" align="center">
  573. <template slot-scope="scope">
  574. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  575. </template>
  576. </el-table-column>
  577. <el-table-column label="是否启用" min-width="130px" align="center">
  578. <template slot-scope="scope">
  579. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  580. </template>
  581. </el-table-column>
  582. </el-table>
  583. </div>
  584. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  585. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  586. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  587. </div>
  588. </div>
  589. </el-dialog>
  590. <!-- 历史记录 -->
  591. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  592. <div class="historyRecord">
  593. <keep-alive>
  594. <component :is="historyRecord.myComponent" ref="historyRecord" />
  595. </keep-alive>
  596. </div>
  597. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  598. <el-button class="cancelClose" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  599. </div>
  600. </el-dialog>
  601. </div>
  602. </template>
  603. <script>
  604. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, checkButtons, ExecDataByConfig, formatNum } from '@/api/common'
  605. import Sortable from 'sortablejs'
  606. import { MessageBox } from 'element-ui'
  607. import Cookies from 'js-cookie'
  608. import { json2excel } from '@/utils/index.js'
  609. import axios from 'axios'
  610. import { getToken } from '@/utils/auth'
  611. import { parseTime } from '@/utils/index.js'
  612. export default {
  613. name: 'RecipeTemplate',
  614. data() {
  615. return {
  616. isFormula: [],
  617. requestParams: [
  618. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  619. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  620. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  621. ],
  622. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  623. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  624. livestockTypeList: [], // 牲畜类别
  625. formulaTypeList: [], // 配方类型
  626. feedNameList: [], // 饲料名称
  627. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  628. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  629. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  630. arrowDown: true,
  631. arrowUp: false,
  632. table: {
  633. getdataListParm: {
  634. name: 'getFTList',
  635. page: 1,
  636. offset: 1,
  637. pagecount: 30,
  638. returntype: 'Map',
  639. parammaps: {
  640. pastureid: Cookies.get('pastureid'),
  641. tname: '',
  642. ccid: '',
  643. ccname: '',
  644. fttypeid: '',
  645. fttype: '',
  646. remark: '',
  647. enable: ''
  648. }
  649. },
  650. tableKey: 0,
  651. list: [],
  652. total: 0,
  653. listLoading: true,
  654. temp: {}
  655. },
  656. lockCount: {
  657. getdataListParm: {
  658. name: 'getSysoptEnable',
  659. page: 1,
  660. offset: 1,
  661. pagecount: 30,
  662. returntype: 'Map',
  663. parammaps: {
  664. pastureid: Cookies.get('pastureid'),
  665. inforname: 'isLockCount'
  666. }
  667. },
  668. isLockCount: false // 是否显示是否锁定牛头数比例
  669. },
  670. isDetail: false,
  671. arrowDown2: true,
  672. arrowUp2: false,
  673. table2: {
  674. getDryweightParm: {
  675. name: 'getFTdryweight',
  676. page: 1,
  677. offset: 1,
  678. pagecount: 10,
  679. returntype: 'Map',
  680. parammaps: {
  681. pastureid: '',
  682. ftid: ''
  683. }
  684. },
  685. dryweight: '',
  686. getdataListParm: {
  687. name: 'getFTdetailList',
  688. page: 1,
  689. offset: 1,
  690. pagecount: '',
  691. returntype: 'Map',
  692. parammaps: {
  693. pastureid: Cookies.get('pastureid'),
  694. fname: '',
  695. feedgroup: '',
  696. fweight: '',
  697. autosecondname: '',
  698. islockcount: '',
  699. sort: ''
  700. }
  701. },
  702. tableKey: 0,
  703. list: [],
  704. total: 0,
  705. listLoading: true,
  706. temp: {}
  707. },
  708. isDetailDialog: false,
  709. template: {
  710. dialogFormVisible: false,
  711. dialogStatus: '',
  712. table: {
  713. getdataListParm: {
  714. name: 'getFTListDate',
  715. page: 1,
  716. offset: 1,
  717. pagecount: '',
  718. returntype: 'Map',
  719. parammaps: {
  720. pastureid: Cookies.get('pastureid'),
  721. tname: '',
  722. ccid: '',
  723. ccname: '',
  724. fttype: '',
  725. remark: '',
  726. enable: '',
  727. date: '',
  728. source: ''
  729. }
  730. },
  731. tableKey: 0,
  732. total: 0,
  733. listLoading: true,
  734. list: []
  735. },
  736. table2: {
  737. getdataListParm: {
  738. name: 'getFTdetailListDate',
  739. page: 1,
  740. offset: 1,
  741. pagecount: 10,
  742. returntype: 'Map',
  743. parammaps: {
  744. pastureid: Cookies.get('pastureid'),
  745. fname: '',
  746. fweight: '',
  747. islockcount: '',
  748. sort: '',
  749. feedgroup: '',
  750. autosecondname: ''
  751. }
  752. },
  753. tableKey: 0,
  754. total: 0,
  755. listLoading: true,
  756. list: []
  757. },
  758. // 历史日期
  759. getdataDateParm: {
  760. name: 'getFTMaxDate',
  761. page: 1,
  762. offset: 1,
  763. pagecount: 10,
  764. returntype: 'Map',
  765. parammaps: {
  766. pastureid: Cookies.get('pastureid')
  767. }
  768. }
  769. },
  770. isOrder: true,
  771. detail: {
  772. dialogFormVisible: false,
  773. dialogStatus: '',
  774. tableKey: 0,
  775. total: 0,
  776. listLoading: true,
  777. list: [],
  778. tableKey2: 0,
  779. total2: 0,
  780. listLoading2: false,
  781. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  782. getdataListParm: {
  783. name: 'getFTDetailCompare',
  784. page: 1,
  785. offset: 1,
  786. pagecount: 10,
  787. returntype: 'Map',
  788. parammaps: {}
  789. },
  790. list3: [],
  791. disabled: false,
  792. getdataListParm2: {
  793. name: 'getFTCompare',
  794. page: 1,
  795. offset: 1,
  796. pagecount: 10,
  797. returntype: 'Map',
  798. parammaps: {}
  799. }
  800. },
  801. selectList: [],
  802. selectList2: [],
  803. textMap: {
  804. RecipeRecord: '配方记录',
  805. SyntheticPremix: '合成预混料',
  806. historyRecord: '历史记录'
  807. },
  808. requestParam: {},
  809. download: {
  810. getdataListParm: {
  811. name: 'getFTList',
  812. page: 1,
  813. offset: 1,
  814. pagecount: 0,
  815. returntype: 'Map',
  816. parammaps: {
  817. pastureid: Cookies.get('pastureid'),
  818. tname: '',
  819. ccid: '',
  820. ccname: '',
  821. fttypeid: '',
  822. fttype: '',
  823. remark: '',
  824. enable: ''
  825. }
  826. },
  827. list: []
  828. },
  829. historyRecord: {
  830. dialogStatus: '',
  831. dialogFormVisible: false
  832. },
  833. isokDisable: false,
  834. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  835. cellStyle: { padding: 0 + 'px' },
  836. dropState: false
  837. }
  838. },
  839. computed: {
  840. // 设置请求头
  841. headers() {
  842. return {
  843. token: getToken()
  844. }
  845. },
  846. uploadData() {
  847. return {
  848. name: '颛孙洋洋-配方模板',
  849. importParams: '配方名称, 牲畜类别, 配方类型, 备注, 是否启用, 饲料组, 饲料名称, 重量(kg), 搅拌延时(min), 是否锁定牛头数比例',
  850. sheetname: 'SheetJS'
  851. }
  852. },
  853. // 设置上传地址
  854. uploadExcelUrl() {
  855. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  856. }
  857. },
  858. mounted() {
  859. document.addEventListener('click', (e) => {
  860. if (this.$refs.selectInput !== undefined) {
  861. if (!this.$refs.selectInput.contains(e.target)) {
  862. this.arrowDown = true
  863. this.arrowUp = false
  864. } else {
  865. this.arrowDown = false
  866. this.arrowUp = true
  867. }
  868. }
  869. if (this.$refs.selectInput2 !== undefined) {
  870. if (!this.$refs.selectInput2.contains(e.target)) {
  871. this.arrowDown2 = true
  872. this.arrowUp2 = false
  873. } else {
  874. this.arrowDown2 = false
  875. this.arrowUp2 = true
  876. }
  877. }
  878. })
  879. },
  880. created() {
  881. this.getList()
  882. this.getButtons()
  883. this.getDownList()
  884. this.getIsLockCount()
  885. },
  886. methods: {
  887. getButtons() {
  888. const Formula = 'FormulationEvaluation'
  889. const isFormula = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Formula)
  890. this.isFormula = isFormula
  891. },
  892. getSummaries(param) {
  893. console.log(param, '====')
  894. const { columns, data } = param
  895. const sums = []
  896. columns.forEach((column, index) => {
  897. if (index === 0) {
  898. sums[index] = '合计'
  899. return
  900. }
  901. // const values = data.map(item => Number(item[column.property]))
  902. // if (!values.every(value => isNaN(value))) {
  903. // sums[index] = values.reduce((prev, curr) => {
  904. // const value = Number(curr)
  905. // if (!isNaN(value)) {
  906. // return prev + curr
  907. // } else {
  908. // return prev
  909. // }
  910. // }, 0)
  911. // // 后台待发
  912. // // var aa = formatNum(, 2)
  913. // sums[index] += '(干物质量:' + this.table2.dryweight + ')'
  914. // } else {
  915. // sums[index] = ''
  916. // }
  917. // sums[index] = sums[index].toFixed(2)
  918. if (column.property !== undefined) {
  919. // 加了prop属性的el-table-column 才能找到column.property
  920. const values = data.map(item => Number(item[column.property]))
  921. if (!values.every(value => isNaN(value))) {
  922. sums[index] = values.reduce((prev, curr) => {
  923. const value = Number(curr)
  924. if (!isNaN(value)) {
  925. return prev + curr // 多行相加
  926. } else {
  927. return prev
  928. }
  929. }, 0)
  930. } else {
  931. sums[index] = ''
  932. }
  933. sums[index] = sums[index].toFixed(2) + '(干物质量:' + this.table2.dryweight + ')'// 保留2位小数
  934. }
  935. })
  936. // console.log(sums, 'sums[index]')
  937. return sums
  938. },
  939. getDryWeight() {
  940. GetDataByName(this.table2.getDryweightParm).then(response => {
  941. console.log('table数据', response.data.list)
  942. if (response.data.list[0].dryweight !== undefined) {
  943. this.table2.dryweight = response.data.list[0].dryweight
  944. } else {
  945. this.table2.dryweight = ''
  946. }
  947. })
  948. },
  949. getTemplateTable2Summaries(param) {
  950. console.log(param, '====')
  951. const { columns, data } = param
  952. const sums = []
  953. columns.forEach((column, index) => {
  954. if (index === 0) {
  955. sums[index] = '合计'
  956. return
  957. }
  958. const values = data.map(item => Number(item[column.property]))
  959. if (!values.every(value => isNaN(value))) {
  960. sums[index] = values.reduce((prev, curr) => {
  961. const value = Number(curr)
  962. if (!isNaN(value)) {
  963. return prev + curr
  964. } else {
  965. return prev
  966. }
  967. }, 0)
  968. // 后台待发
  969. sums[index] += '(干物质量:' + this.template.table2.getdataListParm.parammaps.dryweight + ')'
  970. } else {
  971. sums[index] = ''
  972. }
  973. })
  974. return sums
  975. },
  976. // handleHistory() {
  977. // MessageBox.confirm('是否确认生成历史?', {
  978. // confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  979. // }).then(() => {
  980. // this.requestParam.name = 'creatFTdate'
  981. // this.requestParam.parammaps = {}
  982. // this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  983. // PostDataByName(this.requestParam).then(response => {
  984. // console.log('生成历史保存发送参数', this.requestParam)
  985. // if (response.msg !== 'fail') {
  986. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  987. // } else {
  988. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  989. // }
  990. // })
  991. // })
  992. // },
  993. getDownList() {
  994. GetDataByNames(this.requestParams).then(response => {
  995. this.livestockTypeList = response.data.getDictByName.list
  996. this.formulaTypeList = response.data.getDictByName2.list
  997. this.feedNameList = response.data.getFeedAndPre.list
  998. })
  999. },
  1000. // -------------------模板-----------------------------
  1001. getList() {
  1002. this.table.listLoading = true
  1003. GetDataByName(this.table.getdataListParm).then(response => {
  1004. console.log('table数据', response.data.list)
  1005. if (response.data.list !== null) {
  1006. for (let i = 0; i < response.data.list.length; i++) {
  1007. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1008. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1009. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1010. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1011. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1012. }
  1013. this.table.list = response.data.list
  1014. this.table.pageNum = response.data.pageNum
  1015. this.table.pageSize = response.data.pageSize
  1016. this.table.total = response.data.total
  1017. this.isDetail = true // 点击行显示详情
  1018. this.table2.getdataListParm.parammaps.ftid = response.data.list[0].id
  1019. this.table2.getdataListParm.parammaps.fttypeid = response.data.list[0].fttypeid
  1020. this.table2.getdataListParm.parammaps.dryweight = response.data.list[0].dryweight
  1021. if (response.data.list[0].fttype == '预混配方') {
  1022. this.requestParams[2].parammaps.type = '1'
  1023. } else {
  1024. this.requestParams[2].parammaps.type = ''
  1025. }
  1026. this.getList2()
  1027. this.getDownList()
  1028. } else {
  1029. this.table.list = []
  1030. this.isDetail = false
  1031. }
  1032. setTimeout(() => {
  1033. this.table.listLoading = false
  1034. }, 100)
  1035. })
  1036. },
  1037. getList3() {
  1038. this.table.listLoading = true
  1039. GetDataByName(this.table.getdataListParm).then(response => {
  1040. console.log('table数据', response.data.list)
  1041. if (response.data.list !== null) {
  1042. for (let i = 0; i < response.data.list.length; i++) {
  1043. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1044. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1045. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1046. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1047. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1048. }
  1049. this.table.list = response.data.list
  1050. this.table.pageNum = response.data.pageNum
  1051. this.table.pageSize = response.data.pageSize
  1052. this.table.total = response.data.total
  1053. } else {
  1054. this.table.list = []
  1055. this.isDetail = false
  1056. }
  1057. setTimeout(() => {
  1058. this.table.listLoading = false
  1059. }, 100)
  1060. })
  1061. },
  1062. handleSearch() {
  1063. console.log('点击了查询')
  1064. this.table.getdataListParm.offset = 1
  1065. this.getList()
  1066. this.arrowDown = true
  1067. this.arrowUp = false
  1068. },
  1069. handleRefresh() {
  1070. console.log('点击了重置')
  1071. this.table.getdataListParm.offset = 1
  1072. this.table.getdataListParm.parammaps.ccid = ''
  1073. this.table.getdataListParm.parammaps.ccname = ''
  1074. this.table.getdataListParm.parammaps.fttype = ''
  1075. this.table.getdataListParm.parammaps.tname = ''
  1076. this.table.getdataListParm.parammaps.remark = ''
  1077. this.table.getdataListParm.parammaps.enable = ''
  1078. this.table.getdataListParm.parammaps.source = ''
  1079. this.getList()
  1080. },
  1081. // 模板新增
  1082. handleCreate() {
  1083. console.log('点击了新增')
  1084. // 编辑true/不可编辑false
  1085. // 新增操true,编辑false,编辑保存false
  1086. for (let i = 0; i < this.table.list.length; i++) {
  1087. if (this.table.list[i].Edit === true) {
  1088. console.log(123)
  1089. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1090. return false
  1091. }
  1092. }
  1093. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  1094. console.log(this.table.list)
  1095. },
  1096. // 畜生类别
  1097. changeLivestockType(item) {
  1098. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1099. },
  1100. // 配方类型
  1101. changeFormulaType(item) {
  1102. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  1103. },
  1104. createData(row) {
  1105. console.log('点击了新增保存', row)
  1106. this.table.temp.tname = row.tname
  1107. this.table.temp.tcolor = row.tcolor
  1108. this.table.temp.ccid = row.ccid
  1109. this.table.temp.ccname = this.table.temp.ccname
  1110. this.table.temp.fttype = this.table.temp.fttype
  1111. this.table.temp.fttypeid = row.fttypeid
  1112. this.table.temp.source = row.source
  1113. this.table.temp.remark = row.remark
  1114. this.table.temp.enable = row.enable
  1115. this.table.temp.pastureid = Cookies.get('pastureid')
  1116. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1117. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1118. return false
  1119. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1120. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1121. return false
  1122. } else if (this.table.temp.tname == '') {
  1123. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1124. return false
  1125. } else if (this.table.temp.ccid == '') {
  1126. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1127. return false
  1128. } else if (this.table.temp.fttypeid == '') {
  1129. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1130. return false
  1131. }
  1132. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1133. if (pattern.test(this.table.temp.tname)) {
  1134. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1135. return false
  1136. }
  1137. console.log(this.table.temp)
  1138. this.isokDisable = true
  1139. setTimeout(() => {
  1140. this.isokDisable = false
  1141. }, 1000)
  1142. this.requestParam.name = 'insertFT'
  1143. this.requestParam.parammaps = this.table.temp
  1144. PostDataByName(this.requestParam).then(response => {
  1145. console.log('新增保存发送参数', this.requestParam)
  1146. if (response.msg !== 'fail') {
  1147. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1148. this.getList()
  1149. } else {
  1150. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1151. }
  1152. })
  1153. },
  1154. createCancel(row) {
  1155. console.log('点击了新增取消')
  1156. for (let i = 0; i < this.table.list.length; i++) {
  1157. if (row.myId === this.table.list[i].myId) {
  1158. var listIndex = this.table.list.indexOf(this.table.list[i])
  1159. }
  1160. if (listIndex > -1) {
  1161. this.table.list.splice(listIndex, 1)
  1162. return
  1163. }
  1164. }
  1165. },
  1166. // 模板编辑
  1167. handleUpdate(row) {
  1168. for (let i = 0; i < this.table.list.length; i++) {
  1169. if (this.table.list[i].Edit == true) {
  1170. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1171. return false
  1172. }
  1173. }
  1174. // 编辑true,不可编辑false
  1175. row.Edit = true
  1176. row.NoEdit = false
  1177. // 新增false,编辑false,编辑保存true
  1178. row.isCreate = false
  1179. row.isUpdate = false
  1180. row.isUpdateSave = true
  1181. row.ccid = String(row.ccid)
  1182. row.fttypeid = String(row.fttypeid)
  1183. this.table.temp.ccname = row.ccname
  1184. this.table.temp.fttype = row.fttype
  1185. },
  1186. updateData(row) {
  1187. console.log('点击了编辑保存', row)
  1188. this.table.temp.tname = row.tname
  1189. this.table.temp.tcolor = row.tcolor
  1190. this.table.temp.ccid = row.ccid
  1191. this.table.temp.fttypeid = row.fttypeid
  1192. this.table.temp.source = row.source
  1193. this.table.temp.remark = row.remark
  1194. this.table.temp.enable = row.enable
  1195. this.table.temp.ccname = this.table.temp.ccname
  1196. this.table.temp.fttype = this.table.temp.fttype
  1197. this.table.temp.pastureid = row.pastureid
  1198. this.table.temp.id = row.id
  1199. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1200. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1201. return false
  1202. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1203. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1204. return false
  1205. } else if (this.table.temp.tname == '') {
  1206. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1207. return false
  1208. } else if (this.table.temp.ccid == '') {
  1209. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1210. return false
  1211. } else if (this.table.temp.fttypeid == '') {
  1212. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1213. return false
  1214. }
  1215. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1216. if (pattern.test(this.table.temp.tname)) {
  1217. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1218. return false
  1219. }
  1220. console.log(this.table.temp)
  1221. this.isokDisable = true
  1222. setTimeout(() => {
  1223. this.isokDisable = false
  1224. }, 1000)
  1225. this.requestParam.name = 'updateFT'
  1226. this.requestParam.parammaps = this.table.temp
  1227. PostDataByName(this.requestParam).then(response => {
  1228. console.log('新增保存发送参数', this.requestParam)
  1229. if (response.msg !== 'fail') {
  1230. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1231. this.getList()
  1232. } else {
  1233. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1234. }
  1235. })
  1236. },
  1237. updateCancel(row) {
  1238. console.log('点击了编辑取消')
  1239. // 编辑false,不可编辑true
  1240. row.Edit = false
  1241. row.NoEdit = true
  1242. // 新增false,编辑true,编辑保存false
  1243. row.isCreate = false
  1244. row.isUpdate = true
  1245. row.isUpdateSave = false
  1246. this.getList()
  1247. },
  1248. // 删除
  1249. handleRowDelete(row) {
  1250. console.log('点击了行内删除')
  1251. MessageBox.confirm('是否确认删除此信息?', {
  1252. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1253. }).then(() => {
  1254. this.requestParam.common = { 'returnmap': '0' }
  1255. this.requestParam.data = []
  1256. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1257. pastureid: row.pastureid,
  1258. id: row.id
  1259. }}
  1260. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1261. pastureid: row.pastureid,
  1262. id: row.id
  1263. }}
  1264. ExecDataByConfig(this.requestParam).then(response => {
  1265. console.log('新增保存发送参数', this.requestParam)
  1266. if (response.msg === 'fail') {
  1267. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1268. } else {
  1269. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1270. this.getList()
  1271. this.isDetail = false
  1272. }
  1273. })
  1274. }).catch(() => {
  1275. this.$message({ type: 'info', message: '已取消删除' })
  1276. })
  1277. },
  1278. handleSelectionChange(val) {
  1279. console.log('勾选数据', val)
  1280. this.selectList = val
  1281. },
  1282. handleDelete() {
  1283. console.log('点击了删除')
  1284. if (this.selectList.length == 0) {
  1285. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1286. } else {
  1287. MessageBox.confirm('是否确认删除此信息?', {
  1288. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1289. }).then(() => {
  1290. console.log(this.selectList)
  1291. this.requestParam.common = { 'returnmap': '0' }
  1292. this.requestParam.data = []
  1293. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1294. this.requestParam.data[0].children = []
  1295. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1296. id: '@insertSpotList.id',
  1297. pastureid: '@insertSpotList.pastureid'
  1298. }}
  1299. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1300. id: '@insertSpotList.id',
  1301. pastureid: '@insertSpotList.pastureid'
  1302. }}
  1303. ExecDataByConfig(this.requestParam).then(response => {
  1304. console.log('删除保存发送参数', this.requestParam)
  1305. if (response.msg === 'fail') {
  1306. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1307. } else {
  1308. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1309. this.getList()
  1310. }
  1311. })
  1312. })
  1313. }
  1314. },
  1315. // 复制
  1316. handleCopy() {
  1317. if (this.selectList.length == 0) {
  1318. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1319. } else {
  1320. MessageBox.confirm('是否确认复制此信息?', {
  1321. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1322. }).then(() => {
  1323. console.log(this.selectList)
  1324. this.requestParam.common = { 'returnmap': '0' }
  1325. this.requestParam.data = []
  1326. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1327. this.requestParam.data[0].children = []
  1328. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1329. ftid: '@insertSpotList.id',
  1330. pastureid: '@insertSpotList.pastureid'
  1331. }}
  1332. ExecDataByConfig(this.requestParam).then(response => {
  1333. console.log('复制保存发送参数', this.requestParam)
  1334. if (response.msg === 'fail') {
  1335. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1336. } else {
  1337. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1338. this.getList()
  1339. }
  1340. })
  1341. })
  1342. }
  1343. },
  1344. // 配方记录
  1345. handleRecipeRecord() {
  1346. console.log('点击了配方记录')
  1347. this.template.dialogStatus = 'RecipeRecord'
  1348. this.template.dialogFormVisible = true
  1349. this.template.table.getdataListParm.parammaps.ccname = ''
  1350. this.template.table.getdataListParm.parammaps.fttype = ''
  1351. this.template.table.getdataListParm.parammaps.enable = ''
  1352. this.template.table.getdataListParm.parammaps.tname = ''
  1353. this.template.table.getdataListParm.parammaps.remark = ''
  1354. this.template.table.getdataListParm.parammaps.source = ''
  1355. this.template.table.getdataListParm.offset = 1
  1356. this.getDateList()
  1357. this.isDetailDialog = false
  1358. },
  1359. // 历史时间
  1360. getDateList() {
  1361. GetDataByName(this.template.getdataDateParm).then(response => {
  1362. console.log('table数据', response.data.list)
  1363. if (response.data.list !== null) {
  1364. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1365. this.getTemplateDialogList()
  1366. } else {
  1367. this.template.table.getdataListParm.parammaps.date = ''
  1368. }
  1369. })
  1370. },
  1371. // 配方记录-模板
  1372. getTemplateDialogList() {
  1373. this.template.table.listLoading = true
  1374. GetDataByName(this.template.table.getdataListParm).then(response => {
  1375. console.log('table数据', response.data.list)
  1376. if (response.data.list !== null) {
  1377. this.template.table.list = response.data.list
  1378. this.template.table.pageNum = response.data.pageNum
  1379. this.template.table.pageSize = response.data.pageSize
  1380. this.template.table.total = response.data.total
  1381. } else {
  1382. this.template.table.list = []
  1383. this.template.table2.list = []
  1384. }
  1385. setTimeout(() => {
  1386. this.template.table.listLoading = false
  1387. }, 100)
  1388. })
  1389. },
  1390. handleDialogSearch() {
  1391. this.template.table.getdataListParm.offset = 1
  1392. this.getTemplateDialogList()
  1393. this.arrowDown = true
  1394. this.arrowUp = false
  1395. },
  1396. handleDialogRefresh() {
  1397. this.template.table.getdataListParm.parammaps.ccname = ''
  1398. this.template.table.getdataListParm.parammaps.fttype = ''
  1399. this.template.table.getdataListParm.parammaps.enable = ''
  1400. this.template.table.getdataListParm.parammaps.tname = ''
  1401. this.template.table.getdataListParm.parammaps.remark = ''
  1402. this.template.table.getdataListParm.parammaps.source = ''
  1403. this.template.table.getdataListParm.offset = 1
  1404. this.getTemplateDialogList()
  1405. },
  1406. // 配方记录-模板行点击
  1407. tableRowClickDialog(row, column, event) {
  1408. console.log('配方记录-模板行点击')
  1409. this.isDetailDialog = true
  1410. this.template.table2.getdataListParm.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1411. this.template.table2.getdataListParm.parammaps.version = row.version
  1412. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1413. this.template.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1414. this.getDialogList()
  1415. this.getDownList()
  1416. },
  1417. getDialogList() {
  1418. this.template.table2.listLoading = true
  1419. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1420. console.log('table数据', response.data.list)
  1421. if (response.data.list !== null) {
  1422. this.template.table2.list = response.data.list
  1423. this.template.table2.pageNum = response.data.pageNum
  1424. this.template.table2.pageSize = response.data.pageSize
  1425. this.template.table2.total = response.data.total
  1426. } else {
  1427. this.template.table2.list = []
  1428. }
  1429. this.$nextTick(function() {
  1430. document.querySelector('#detailDialog2').scrollIntoView()
  1431. // window.scrollTo({
  1432. // 'top': this.$refs.detailDialog2.clientHeight
  1433. // })
  1434. })
  1435. setTimeout(() => {
  1436. this.template.table2.listLoading = false
  1437. }, 100)
  1438. })
  1439. },
  1440. handleDialogSearch2() {
  1441. console.log('点击了查询')
  1442. this.arrowDown2 = true
  1443. this.arrowUp2 = false
  1444. this.template.table2.getdataListParm.offset = 1
  1445. this.getDialogList2()
  1446. },
  1447. handleDialogRefresh2() {
  1448. console.log('点击了重置')
  1449. this.template.table2.getdataListParm.parammaps.fname = ''
  1450. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1451. this.template.table2.getdataListParm.parammaps.fweight = ''
  1452. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1453. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1454. this.template.table2.getdataListParm.parammaps.sort = ''
  1455. this.template.table2.getdataListParm.offset = 1
  1456. this.getDialogList2()
  1457. },
  1458. getDialogList2() {
  1459. this.template.table2.listLoading = true
  1460. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1461. console.log('table数据', response.data.list)
  1462. if (response.data.list !== null) {
  1463. this.template.table2.list = response.data.list
  1464. this.template.table2.pageNum = response.data.pageNum
  1465. this.template.table2.pageSize = response.data.pageSize
  1466. this.template.table2.total = response.data.total
  1467. } else {
  1468. this.template.table2.list = []
  1469. }
  1470. this.$nextTick(function() {
  1471. window.scrollTo({
  1472. 'top': this.$refs.templateDialog.clientHeight
  1473. })
  1474. })
  1475. setTimeout(() => {
  1476. this.template.table2.listLoading = false
  1477. }, 100)
  1478. })
  1479. },
  1480. // 导出
  1481. handleExport(item) {
  1482. if (item == 1) {
  1483. console.log('点击了导出模板')
  1484. const requestParam = this.requestParam
  1485. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/配方计划/配方模板导入模板.xlsx' // 请求下载文件的地址
  1486. console.log(url)
  1487. axios({
  1488. method: 'GET',
  1489. url: url,
  1490. data: requestParam,
  1491. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1492. responseType: 'blob'
  1493. }).then(res => {
  1494. if (!res) return
  1495. this.percentage = 99
  1496. setTimeout(() => {
  1497. this.isPercentage = false
  1498. }, 2000)
  1499. const blob = new Blob([res.data], {
  1500. type: 'application/octet-stream;charset=utf-8'
  1501. })
  1502. const url = window.URL.createObjectURL(blob)
  1503. const aLink = document.createElement('a')
  1504. aLink.style.display = 'none'
  1505. aLink.href = url
  1506. const docname = '配方模板导入模板.xlsx'
  1507. aLink.setAttribute('download', docname) // 下载的文件
  1508. document.body.appendChild(aLink)
  1509. aLink.click()
  1510. document.body.removeChild(aLink)
  1511. window.URL.revokeObjectURL(url)
  1512. })
  1513. } else {
  1514. console.log('点击了导出数据')
  1515. this.download.getdataListParm.name = 'downloadFTList'
  1516. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1517. GetDataByName(this.download.getdataListParm).then(response => {
  1518. if (response.data.list !== null) {
  1519. for (let i = 0; i < response.data.list.length; i++) {
  1520. if (response.data.list[i].islockcount == 0) {
  1521. this.$set(response.data.list[i], 'islockcount', '否')
  1522. } else {
  1523. this.$set(response.data.list[i], 'islockcount', '是')
  1524. }
  1525. if (response.data.list[i].enable == 0) {
  1526. this.$set(response.data.list[i], 'enable', '否')
  1527. } else {
  1528. this.$set(response.data.list[i], 'enable', '是')
  1529. }
  1530. }
  1531. this.download.list = response.data.list
  1532. } else {
  1533. this.download.list = []
  1534. }
  1535. var excelDatas = [
  1536. {
  1537. tHeader: ['配方名称', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1538. filterVal: ['tname', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1539. tableDatas: this.download.list,
  1540. sheetName: 'Sheet1'
  1541. }
  1542. ]
  1543. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1544. })
  1545. }
  1546. },
  1547. beforeImport(file) {
  1548. const isLt2M = file.size / 1024 / 1024 < 2
  1549. if (!isLt2M) {
  1550. this.$message.error('上传文件大小不能超过 2MB!')
  1551. }
  1552. return isLt2M
  1553. },
  1554. handleImportSuccess(res, file) {
  1555. this.getList()
  1556. if (res.msg === 'ok') {
  1557. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1558. if (res.data.err_count > 0) {
  1559. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1560. import('@/vendor/Export2Excel').then(excel => {
  1561. const list1 = res.data.result
  1562. const tHeader = [
  1563. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1564. ]
  1565. const filterVal = [
  1566. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1567. ]
  1568. const data1 = this.formatJson(filterVal, list1)
  1569. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1570. })
  1571. }
  1572. } else {
  1573. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1574. }
  1575. },
  1576. formatJson(filterVal, jsonData) {
  1577. return jsonData.map(v =>
  1578. filterVal.map(j => {
  1579. if (j === 'timestamp') {
  1580. return parseTime(v[j])
  1581. } else {
  1582. return v[j]
  1583. }
  1584. })
  1585. )
  1586. },
  1587. changeDate() {
  1588. this.getTemplateDialogList()
  1589. },
  1590. // 应用
  1591. handleApplication() {
  1592. console.log('点击了应用')
  1593. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1594. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1595. }).then(() => {
  1596. this.requestParam.name = 'applyFTdate'
  1597. this.requestParam.parammaps = {}
  1598. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1599. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1600. PostDataByName(this.requestParam).then(response => {
  1601. if (response.msg === 'fail') {
  1602. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1603. } else {
  1604. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1605. this.getTemplateDialogList()
  1606. this.getList()
  1607. }
  1608. })
  1609. }).catch(() => {
  1610. this.$message({ type: 'info', message: '已取消应用' })
  1611. })
  1612. },
  1613. // 模板行点击
  1614. tableRowClick(row, column, event) {
  1615. console.log(row, column, event)
  1616. for (let i = 0; i < this.table.list.length; i++) {
  1617. if (this.table.list[i].Edit == true) {
  1618. return false
  1619. }
  1620. }
  1621. console.log(this.isOrder)
  1622. if (this.isOrder == false) {
  1623. this.$message({ type: 'error', message: '请保存或取消当前更改顺序操作', duration: 2000 })
  1624. } else {
  1625. if (column.label !== '操作') {
  1626. this.isDetail = true // 点击行显示详情
  1627. this.table2.getdataListParm.parammaps.ftid = row.id
  1628. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1629. this.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1630. if (row.fttype == '预混配方') {
  1631. this.requestParams[2].parammaps.type = '1'
  1632. } else {
  1633. this.requestParams[2].parammaps.type = ''
  1634. }
  1635. this.getList2()
  1636. this.getDownList()
  1637. this.$nextTick(function() {
  1638. window.scrollTo({
  1639. 'top': this.$refs.template.clientHeight
  1640. })
  1641. })
  1642. }
  1643. }
  1644. },
  1645. // -------------------详情-----------------------------
  1646. // 获取是否显示是否锁定牛头数
  1647. getIsLockCount() {
  1648. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1649. console.log(response.data.list)
  1650. if (response.data.list[0].inforvalue == 0) {
  1651. this.lockCount.isLockCount = false
  1652. } else {
  1653. this.lockCount.isLockCount = true
  1654. }
  1655. })
  1656. },
  1657. // 详情
  1658. getList2() {
  1659. this.table2.listLoading = true
  1660. GetDataByName(this.table2.getdataListParm).then(response => {
  1661. console.log('table数据', response.data.list)
  1662. if (response.data.list !== null) {
  1663. for (let i = 0; i < response.data.list.length; i++) {
  1664. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1665. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1666. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1667. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1668. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1669. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1670. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1671. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1672. console.log(this.table2.getdataListParm.parammaps)
  1673. console.log(this.table2, '===')
  1674. }
  1675. this.table2.getDryweightParm.parammaps = this.table2.getdataListParm.parammaps
  1676. this.getDryWeight()
  1677. this.table2.list = response.data.list
  1678. this.table2.pageNum = response.data.pageNum
  1679. this.table2.pageSize = response.data.pageSize
  1680. this.table2.total = response.data.total
  1681. } else {
  1682. this.table2.list = []
  1683. }
  1684. setTimeout(() => {
  1685. this.table2.listLoading = false
  1686. }, 100)
  1687. })
  1688. },
  1689. // 行拖拽
  1690. rowDrop() {
  1691. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1692. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1693. // this.sorTable()
  1694. const that = this
  1695. // Sortable.create(tbody, {
  1696. var sortable = Sortable.create(tbody, {
  1697. disabled: that.dropState,
  1698. onChoose({ newIndex, oldIndex }) {
  1699. console.log(that.isOrder, 'that.isOrder == false')
  1700. console.log(that.dropState, 'that.dropState')
  1701. if (that.dropState == true || that.isOrder == true) {
  1702. sortable.destroy()
  1703. }
  1704. },
  1705. onEnd({ newIndex, oldIndex }) {
  1706. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1707. that.table2.list.splice(newIndex, 0, currRow)
  1708. console.log('索引', newIndex)
  1709. console.log('拖动数据', currRow)
  1710. console.log('上', that.table2.list[newIndex - 1])
  1711. console.log('下', that.table2.list[newIndex + 1])
  1712. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1713. for (let i = 0; i < that.table2.list.length; i++) {
  1714. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1715. }
  1716. currRow.sort = 0
  1717. currRow.feedgroup = currRow.fname
  1718. console.log('拖动至最上方无值')
  1719. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1720. currRow.sort = that.table2.list[newIndex - 1].sort
  1721. console.log('拖动值顺序等于上值顺序')
  1722. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1723. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1724. currRow.feedgroup = currRow.fname
  1725. console.log('拖动至最下方无值')
  1726. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1727. currRow.sort == that.table2.list[newIndex + 1].sort
  1728. console.log('拖动值顺序等于下值顺序')
  1729. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1730. currRow.sort = that.table2.list[newIndex - 1].sort
  1731. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1732. console.log('拖动至上下顺序一致')
  1733. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1734. console.log('上下')
  1735. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1736. console.log(newIndex)
  1737. for (let i = newIndex; i < that.table2.list.length; i++) {
  1738. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1739. }
  1740. }
  1741. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1742. currRow.feedgroup = currRow.fname
  1743. console.log(that.table2.list[newIndex + 1].sort)
  1744. }
  1745. }
  1746. })
  1747. console.log(sortable.option('disabled'))
  1748. },
  1749. handleChangeOrder() {
  1750. this.isOrder = false
  1751. this.rowDrop()
  1752. },
  1753. saveChangeOrder() {
  1754. // 保存顺序
  1755. console.log(this.table2.list)
  1756. this.requestParam = {}
  1757. this.requestParam.common = { 'returnmap': '0' }
  1758. this.requestParam.data = []
  1759. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table2.list }}
  1760. this.requestParam.data[0].children = []
  1761. this.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1762. id: '@insertSpotList.id',
  1763. pastureid: '@insertSpotList.pastureid',
  1764. sort: '@insertSpotList.sort',
  1765. feedgroup: '@insertSpotList.feedgroup'
  1766. }}
  1767. ExecDataByConfig(this.requestParam).then(response => {
  1768. console.log('顺序切换保存发送参数', this.requestParam)
  1769. if (response.msg === 'fail') {
  1770. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1771. } else {
  1772. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1773. this.getList2()
  1774. this.getList3()
  1775. this.isOrder = true
  1776. }
  1777. })
  1778. },
  1779. cancelChangeOrder() {
  1780. // 取消顺序
  1781. this.getList2()
  1782. this.isOrder = true
  1783. },
  1784. handleSearch2() {
  1785. console.log('点击了查询')
  1786. this.arrowDown2 = true
  1787. this.arrowUp2 = false
  1788. this.table2.getdataListParm.offset = 1
  1789. this.getList2()
  1790. },
  1791. handleRefresh2() {
  1792. console.log('点击了重置')
  1793. this.table2.getdataListParm.parammaps.fname = ''
  1794. this.table2.getdataListParm.parammaps.feedgroup = ''
  1795. this.table2.getdataListParm.parammaps.fweight = ''
  1796. this.table2.getdataListParm.parammaps.autosecondname = ''
  1797. this.table2.getdataListParm.parammaps.islockcount = '0'
  1798. this.table2.getdataListParm.parammaps.sort = ''
  1799. this.table2.getdataListParm.offset = 1
  1800. this.getList2()
  1801. },
  1802. // 详情新增
  1803. handleCreate2() {
  1804. console.log('点击了详情新增', this.table2.list)
  1805. // 编辑true/不可编辑false
  1806. // 新增操true,编辑false,编辑保存false
  1807. console.log(11)
  1808. for (let i = 0; i < this.table2.list.length; i++) {
  1809. if (this.table2.list[i].Edit === true) {
  1810. console.log(123)
  1811. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1812. return false
  1813. }
  1814. }
  1815. console.log(this.table2.list)
  1816. if (this.table2.list.length == 0) {
  1817. var mysort = 0
  1818. } else {
  1819. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1820. }
  1821. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1822. console.log(this.table2.list)
  1823. },
  1824. changeFname(item, row) {
  1825. console.log(item, row)
  1826. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1827. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1828. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1829. this.table2.temp.preftid = '0'
  1830. } else {
  1831. this.table2.temp.preftid = item
  1832. }
  1833. if (row.sort == '') {
  1834. row.feedgroup = this.table2.temp.fname
  1835. } else {
  1836. if (row.isCreate == true) { // 新增状态下
  1837. for (let i = 1; i < this.table2.list.length; i++) {
  1838. if (this.table2.list[i].sort == row.sort) {
  1839. console.log(this.table2.list[i])
  1840. row.feedgroup = this.table2.list[i].feedgroup
  1841. break
  1842. } else {
  1843. row.feedgroup = this.table2.temp.fname
  1844. }
  1845. }
  1846. } else if (row.isUpdateSave == true) { // 编辑状态下
  1847. var Arr = []
  1848. for (let i = 0; i < this.table2.list.length; i++) {
  1849. Arr.push(this.table2.list[i].sort)
  1850. }
  1851. var Count = 0
  1852. for (let i = 0; i < Arr.length; i++) {
  1853. if (Arr[i] == row.sort) {
  1854. Count++
  1855. }
  1856. }
  1857. for (let i = 0; i < this.table2.list.length; i++) {
  1858. if (Count > 1) {
  1859. row.feedgroup = this.table2.list[i].feedgroup
  1860. console.log(this.table2.list[i].feedgroup)
  1861. break
  1862. } else if (Count == 1) {
  1863. row.feedgroup = this.table2.temp.fname
  1864. console.log(222, this.table2.temp.fname)
  1865. }
  1866. }
  1867. }
  1868. }
  1869. },
  1870. bort(row) {
  1871. if (row.isCreate == true) {
  1872. if (row.sort !== '') {
  1873. for (let i = 1; i < this.table2.list.length; i++) {
  1874. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1875. row.feedgroup = this.table2.list[i].feedgroup
  1876. return false
  1877. } else {
  1878. row.feedgroup = row.fname
  1879. }
  1880. }
  1881. } else {
  1882. row.feedgroup = row.fname
  1883. }
  1884. } else if (row.isUpdateSave == true) {
  1885. if (row.sort !== '') {
  1886. for (let i = 0; i < this.table2.list.length; i++) {
  1887. if (this.table2.list[i].sort == row.sort) {
  1888. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1889. if (this.table2.list[i].id !== row.id) {
  1890. row.isGroupDisabled = true
  1891. row.feedgroup = this.table2.list[i].feedgroup
  1892. break
  1893. }
  1894. } else {
  1895. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1896. row.isGroupDisabled = true
  1897. row.feedgroup = row.fname
  1898. }
  1899. }
  1900. } else {
  1901. row.feedgroup = row.fname
  1902. }
  1903. }
  1904. },
  1905. createData2(row) {
  1906. console.log('点击了详情新增保存', row)
  1907. this.table2.temp.pastureid = Cookies.get('pastureid')
  1908. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1909. this.table2.temp.fid = row.fid
  1910. this.table2.temp.fname = this.table2.temp.fname
  1911. this.table2.temp.fweight = row.fweight
  1912. this.table2.temp.islockcount = row.islockcount
  1913. this.table2.temp.sort = row.sort
  1914. this.table2.temp.feedgroup = row.feedgroup
  1915. this.table2.temp.preftid = this.table2.temp.preftid
  1916. this.table2.temp.autosecond = row.autosecond
  1917. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1918. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1919. return false
  1920. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1921. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1922. return false
  1923. } else if (this.table2.temp.fid == '') {
  1924. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1925. return false
  1926. } else if (this.table2.temp.fweight == '') {
  1927. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1928. return false
  1929. } else if (this.table2.temp.autosecond == '') {
  1930. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1931. return false
  1932. }
  1933. if (this.table2.temp.sort !== '') {
  1934. this.table2.temp.sort = this.table2.temp.sort
  1935. } else {
  1936. console.log(this.table2.list.length)
  1937. if (this.table2.list.length == 1) {
  1938. this.table2.temp.sort = 0
  1939. } else {
  1940. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1941. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1942. }
  1943. }
  1944. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1945. if (parseInt(this.table2.temp.preftid) > 0) {
  1946. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1947. return false
  1948. }
  1949. }
  1950. // 校验顺序是否>=0
  1951. var ruleSort = /^\d+$/
  1952. if (!ruleSort.test(this.table2.temp.sort)) {
  1953. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1954. return false
  1955. }
  1956. // 检验重量>0
  1957. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  1958. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1959. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1960. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1961. return false
  1962. }
  1963. this.isokDisable = true
  1964. setTimeout(() => {
  1965. this.isokDisable = false
  1966. }, 1000)
  1967. this.requestParam.common = { 'returnmap': '0' }
  1968. this.requestParam.data = []
  1969. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1970. pastureid: this.table2.temp.pastureid,
  1971. ftid: this.table2.getdataListParm.parammaps.ftid,
  1972. fid: row.fid,
  1973. fname: this.table2.temp.fname,
  1974. fweight: row.fweight,
  1975. islockcount: row.islockcount,
  1976. sort: row.sort,
  1977. feedgroup: row.feedgroup,
  1978. preftid: this.table2.temp.preftid,
  1979. autosecond: row.autosecond
  1980. }}
  1981. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1982. pastureid: this.table2.temp.pastureid,
  1983. ftid: this.table2.getdataListParm.parammaps.ftid,
  1984. type: this.table2.getdataListParm.parammaps.fttypeid
  1985. }}
  1986. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  1987. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  1988. id: this.table2.getdataListParm.parammaps.ftid
  1989. }}
  1990. ExecDataByConfig(this.requestParam).then(response => {
  1991. console.log('新增保存发送参数', this.requestParam)
  1992. if (response.msg !== 'fail') {
  1993. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1994. this.getList2()
  1995. this.getList3()
  1996. } else {
  1997. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1998. }
  1999. })
  2000. },
  2001. createCancel2(row) {
  2002. console.log('点击了详情新增取消')
  2003. for (let i = 0; i < this.table2.list.length; i++) {
  2004. if (row.myId === this.table2.list[i].myId) {
  2005. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  2006. }
  2007. if (listIndex > -1) {
  2008. this.table2.list.splice(listIndex, 1)
  2009. return
  2010. }
  2011. }
  2012. this.getDialogList()
  2013. },
  2014. // 详情编辑
  2015. handleUpdate2(row) {
  2016. console.log('详情编辑', row)
  2017. this.dropState = true
  2018. row.isGroupDisabled = false
  2019. row.islockcount = String(row.islockcount)
  2020. row.fid = String(row.fid)
  2021. row.autosecond = String(row.autosecond)
  2022. this.table2.temp.fname = row.fname
  2023. this.table2.temp.preftid = row.preftid
  2024. const rowArr = []
  2025. for (let i = 0; i < this.table2.list.length; i++) {
  2026. if (this.table2.list[i].Edit == true) {
  2027. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  2028. return false
  2029. }
  2030. rowArr.push(this.table2.list[i].sort)
  2031. }
  2032. var count = 0
  2033. for (let i = 0; i < rowArr.length; i++) {
  2034. if (rowArr[i] == row.sort) {
  2035. count++
  2036. }
  2037. }
  2038. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  2039. if (count == 1) {
  2040. // 饲料组编辑false,不可编辑true
  2041. row.groupEdit = false
  2042. row.groupNoEdit = true
  2043. // 编辑true,不可编辑false
  2044. row.Edit = true
  2045. row.NoEdit = false
  2046. // 新增false,编辑false,编辑保存true
  2047. row.isCreate = false
  2048. row.isUpdate = false
  2049. row.isUpdateSave = true
  2050. } else if (count > 1) {
  2051. // 饲料组编辑true,不可编辑false
  2052. row.groupEdit = true
  2053. row.groupNoEdit = false
  2054. console.log(222)
  2055. // 编辑true,不可编辑false
  2056. row.Edit = true
  2057. row.NoEdit = false
  2058. // 新增false,编辑false,编辑保存true
  2059. row.isCreate = false
  2060. row.isUpdate = false
  2061. row.isUpdateSave = true
  2062. return false
  2063. }
  2064. },
  2065. updateData2(row) {
  2066. console.log('点击了详情编辑保存', row)
  2067. this.isokDisable = true
  2068. setTimeout(() => {
  2069. this.isokDisable = false
  2070. }, 1000)
  2071. this.table2.temp.pastureid = row.pastureid
  2072. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  2073. this.table2.temp.fid = row.fid
  2074. this.table2.temp.fname = this.table2.temp.fname
  2075. this.table2.temp.fweight = row.fweight
  2076. this.table2.temp.islockcount = row.islockcount
  2077. this.table2.temp.sort = row.sort
  2078. this.table2.temp.feedgroup = row.feedgroup
  2079. this.table2.temp.preftid = this.table2.temp.preftid
  2080. this.table2.temp.autosecond = row.autosecond
  2081. this.table2.temp.id = row.id
  2082. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2083. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  2084. return false
  2085. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2086. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  2087. return false
  2088. } else if (this.table2.temp.fid == '') {
  2089. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2090. return false
  2091. } else if (this.table2.temp.fweight == '') {
  2092. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2093. return false
  2094. } else if (this.table2.temp.autosecond == '') {
  2095. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2096. return false
  2097. }
  2098. if (this.table2.temp.sort !== '') {
  2099. this.table2.temp.sort = this.table2.temp.sort
  2100. } else {
  2101. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2102. }
  2103. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2104. if (parseInt(this.table2.temp.preftid) > 0) {
  2105. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2106. return false
  2107. }
  2108. }
  2109. // 校验顺序是否>=0
  2110. var ruleSort = /^\d+$/
  2111. if (!ruleSort.test(this.table2.temp.sort)) {
  2112. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2113. return false
  2114. }
  2115. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  2116. // 检验重量>0
  2117. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2118. if (!ruleWeight.test(this.table2.temp.fweight)) {
  2119. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  2120. return false
  2121. }
  2122. this.requestParam.common = { 'returnmap': '0' }
  2123. this.requestParam.data = []
  2124. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  2125. pastureid: row.pastureid,
  2126. ftid: this.table2.getdataListParm.parammaps.ftid,
  2127. fid: row.fid,
  2128. fname: this.table2.temp.fname,
  2129. fweight: row.fweight,
  2130. islockcount: row.islockcount,
  2131. sort: row.sort,
  2132. feedgroup: row.feedgroup,
  2133. preftid: this.table2.temp.preftid,
  2134. autosecond: row.autosecond,
  2135. id: row.id
  2136. }}
  2137. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2138. pastureid: row.pastureid,
  2139. ftid: this.table2.getdataListParm.parammaps.ftid,
  2140. type: this.table2.getdataListParm.parammaps.fttypeid
  2141. }}
  2142. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  2143. pastureid: row.pastureid,
  2144. ftid: this.table2.getdataListParm.parammaps.ftid,
  2145. sort: row.sort,
  2146. feedgroup: row.feedgroup
  2147. }}
  2148. this.requestParam.data[3] = { 'name': 'updateFTdetailGroup', 'type': 'e', 'parammaps': {
  2149. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2150. ftid: this.table2.getdataListParm.parammaps.ftid
  2151. }}
  2152. ExecDataByConfig(this.requestParam).then(response => {
  2153. console.log('新增保存发送参数', this.requestParam)
  2154. if (response.msg !== 'fail') {
  2155. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2156. this.getList2()
  2157. this.getList3()
  2158. this.dropState = false
  2159. } else {
  2160. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2161. }
  2162. })
  2163. },
  2164. updateCancel2(row) {
  2165. console.log('点击了详情编辑取消')
  2166. // 饲料组编辑false,不可编辑true
  2167. row.groupEdit = false
  2168. row.groupNoEdit = true
  2169. // 编辑false,不可编辑true
  2170. row.Edit = false
  2171. row.NoEdit = true
  2172. // 新增false,编辑true,编辑保存false
  2173. row.isCreate = false
  2174. row.isUpdate = true
  2175. row.isUpdateSave = false
  2176. this.getList2()
  2177. this.dropState = false
  2178. },
  2179. // 详情删除
  2180. handleRowDelete2(row) {
  2181. console.log('点击了行内删除')
  2182. MessageBox.confirm('是否确认删除此信息?', {
  2183. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2184. }).then(() => {
  2185. console.log(this.table2.list.length)
  2186. if (this.table2.list.length > 1) {
  2187. this.requestParam.common = { 'returnmap': '0' }
  2188. this.requestParam.data = []
  2189. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2190. pastureid: row.pastureid,
  2191. id: row.id
  2192. }}
  2193. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2194. pastureid: row.pastureid,
  2195. ftid: this.table2.getdataListParm.parammaps.ftid,
  2196. type: this.table2.getdataListParm.parammaps.fttypeid
  2197. }}
  2198. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2199. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2200. id: this.table2.getdataListParm.parammaps.ftid
  2201. }}
  2202. } else {
  2203. this.requestParam.common = { 'returnmap': '0' }
  2204. this.requestParam.data = []
  2205. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2206. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2207. id: this.table2.getdataListParm.parammaps.ftid
  2208. }}
  2209. this.requestParam.data[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2210. pastureid: row.pastureid,
  2211. id: row.id
  2212. }}
  2213. this.requestParam.data[2] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2214. pastureid: row.pastureid,
  2215. ftid: this.table2.getdataListParm.parammaps.ftid,
  2216. type: this.table2.getdataListParm.parammaps.fttypeid
  2217. }}
  2218. this.requestParam.data[3] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2219. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2220. id: this.table2.getdataListParm.parammaps.ftid
  2221. }}
  2222. }
  2223. ExecDataByConfig(this.requestParam).then(response => {
  2224. console.log('新增保存发送参数', this.requestParam)
  2225. if (response.msg === 'fail') {
  2226. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2227. } else {
  2228. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2229. this.getList2()
  2230. this.getList3()
  2231. }
  2232. })
  2233. }).catch(() => {
  2234. this.$message({ type: 'info', message: '已取消删除' })
  2235. })
  2236. },
  2237. handleSelectionChange2(val) {
  2238. console.log('勾选数据', val)
  2239. this.selectList2 = val
  2240. },
  2241. handleDelete2() {
  2242. console.log('点击了删除')
  2243. if (this.selectList2.length == 0) {
  2244. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2245. } else {
  2246. MessageBox.confirm('是否确认删除此信息?', {
  2247. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2248. }).then(() => {
  2249. console.log(this.table2.list.length - this.selectList2.length)
  2250. if (this.table2.list.length - this.selectList2.length > 0) {
  2251. this.requestParam.common = { 'returnmap': '0' }
  2252. this.requestParam.data = []
  2253. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2254. this.requestParam.data[0].children = []
  2255. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2256. id: '@insertSpotList.id',
  2257. pastureid: '@insertSpotList.pastureid'
  2258. }}
  2259. this.requestParam.data[1] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2260. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2261. id: this.table2.getdataListParm.parammaps.ftid
  2262. }}
  2263. } else {
  2264. this.requestParam.common = { 'returnmap': '0' }
  2265. this.requestParam.data = []
  2266. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2267. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2268. id: this.table2.getdataListParm.parammaps.ftid
  2269. }}
  2270. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2271. this.requestParam.data[1].children = []
  2272. this.requestParam.data[1].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2273. id: '@insertSpotList.id',
  2274. pastureid: '@insertSpotList.pastureid'
  2275. }}
  2276. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2277. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2278. id: this.table2.getdataListParm.parammaps.ftid
  2279. }}
  2280. }
  2281. ExecDataByConfig(this.requestParam).then(response => {
  2282. console.log('删除保存发送参数', this.requestParam)
  2283. if (response.msg === 'fail') {
  2284. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2285. } else {
  2286. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  2287. this.getList2()
  2288. this.getList3()
  2289. }
  2290. })
  2291. })
  2292. }
  2293. },
  2294. // 拆分预混料
  2295. handleSplitPremix(row) {
  2296. console.log('点击了拆分预混料')
  2297. MessageBox.confirm('是否确认拆分当前预混料?', {
  2298. confirmButtonText: '确认',
  2299. cancelButtonText: '取消',
  2300. type: 'warning'
  2301. }).then(() => {
  2302. this.requestParam.name = 'splitFTpre'
  2303. this.requestParam.parammaps = {}
  2304. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2305. this.requestParam.parammaps.preftid = row.preftid
  2306. this.requestParam.parammaps.ftdid = row.id
  2307. this.requestParam.parammaps.pastureid = row.pastureid
  2308. this.requestParam.parammaps.feedgroup = row.feedgroup
  2309. this.requestParam.parammaps.sort = row.sort
  2310. this.requestParam.parammaps.fweight = row.fweight
  2311. PostDataByName(this.requestParam).then(response => {
  2312. if (response.msg === 'fail') {
  2313. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2314. } else {
  2315. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2316. this.getList2()
  2317. this.getList3()
  2318. }
  2319. })
  2320. }).catch(() => {
  2321. this.$message({
  2322. type: 'info',
  2323. message: '已取消删除'
  2324. })
  2325. })
  2326. },
  2327. // 合成预混料
  2328. handleSyntheticPremix() {
  2329. console.log('点击了合成预混料', this.selectList2)
  2330. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2331. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2332. return false
  2333. } else {
  2334. if (this.selectList2.length > 1) {
  2335. for (let i = 0; i < this.selectList2.length; i++) {
  2336. if (parseInt(this.selectList2[i].preftid) > 0) {
  2337. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2338. return false
  2339. }
  2340. }
  2341. if (this.selectList2[0].splitftpreid !== undefined) {
  2342. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2343. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2344. GetDataByName(this.detail.getdataListParm).then(response => {
  2345. if (response.data.list !== null) { // 不为空时得到比对数据
  2346. this.detail.list3 = response.data.list
  2347. const sortList = [] // 声明排序数组
  2348. var fweightSum = 0 // 总重量
  2349. for (let i = 0; i < this.selectList2.length; i++) {
  2350. const obj = {}
  2351. obj.fid = this.selectList2[i].fid
  2352. obj.fweight = this.selectList2[i].fweight
  2353. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2354. sortList.push(obj)
  2355. }
  2356. // 排序
  2357. sortList.sort(function(a, b) {
  2358. return a.fid.localeCompare(b.fid)
  2359. })
  2360. var a = 0
  2361. if (this.detail.list3.length == sortList.length) {
  2362. for (let i = 0; i < this.detail.list3.length; i++) {
  2363. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  2364. a++
  2365. }
  2366. }
  2367. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2368. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2369. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2370. GetDataByName(this.detail.getdataListParm2).then(response => {
  2371. if (response.data.list !== null) {
  2372. this.detail.dialogStatus = 'SyntheticPremix'
  2373. this.detail.dialogFormVisible = true
  2374. this.detail.list = this.selectList2
  2375. this.detail.list2 = response.data.list
  2376. this.detail.disabled = true
  2377. setTimeout(() => {
  2378. this.detail.listLoading = false
  2379. }, 100)
  2380. } else {
  2381. this.detail.list2 = []
  2382. }
  2383. })
  2384. } else {
  2385. this.detail.dialogStatus = 'SyntheticPremix'
  2386. this.detail.dialogFormVisible = true
  2387. this.detail.list = this.selectList2
  2388. this.detail.disabled = false
  2389. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2390. setTimeout(() => {
  2391. this.detail.listLoading = false
  2392. }, 100)
  2393. }
  2394. } else {
  2395. this.detail.dialogStatus = 'SyntheticPremix'
  2396. this.detail.dialogFormVisible = true
  2397. this.detail.list = this.selectList2
  2398. this.detail.disabled = false
  2399. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2400. setTimeout(() => {
  2401. this.detail.listLoading = false
  2402. }, 100)
  2403. }
  2404. } else {
  2405. this.detail.list3 = []
  2406. this.detail.dialogStatus = 'SyntheticPremix'
  2407. this.detail.dialogFormVisible = true
  2408. this.detail.list = this.selectList2
  2409. this.detail.disabled = false
  2410. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2411. setTimeout(() => {
  2412. this.detail.listLoading = false
  2413. }, 100)
  2414. }
  2415. })
  2416. } else {
  2417. this.detail.dialogStatus = 'SyntheticPremix'
  2418. this.detail.dialogFormVisible = true
  2419. this.detail.list = this.selectList2
  2420. this.detail.disabled = false
  2421. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2422. setTimeout(() => {
  2423. this.detail.listLoading = false
  2424. }, 100)
  2425. }
  2426. } else {
  2427. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2428. return false
  2429. }
  2430. }
  2431. },
  2432. // 畜生类别
  2433. changeLivestockType2(item) {
  2434. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2435. },
  2436. syntheticPremixData() {
  2437. console.log('点击了合成预混料确认')
  2438. if (this.detail.disabled == true) { // 原预混料
  2439. let sumFweight = 0
  2440. for (let i = 0; i < this.detail.list.length; i++) {
  2441. sumFweight += parseFloat(this.detail.list[i].fweight)
  2442. }
  2443. sumFweight = sumFweight.toFixed(2)
  2444. this.isokDisable = true
  2445. setTimeout(() => {
  2446. this.isokDisable = false
  2447. }, 1000)
  2448. this.requestParam.common = { 'returnmap': '0' }
  2449. this.requestParam.data = []
  2450. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2451. this.requestParam.data[0].children = []
  2452. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2453. pastureid: '@insertSpotList.pastureid',
  2454. id: '@insertSpotList.id'
  2455. }}
  2456. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2457. this.requestParam.data[1].children = []
  2458. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2459. pastureid: Cookies.get('pastureid'),
  2460. ftid: this.table2.getdataListParm.parammaps.ftid,
  2461. fid: this.detail.list2[0].id,
  2462. fname: '@insertSpotList2.tname',
  2463. fweight: sumFweight,
  2464. islockcount: '0',
  2465. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2466. feedgroup: '@insertSpotList2.tname',
  2467. preftid: this.detail.list2[0].id,
  2468. autosecond: this.detail.list[0].autosecond
  2469. }}
  2470. ExecDataByConfig(this.requestParam).then(response => {
  2471. console.log('合成预混料保存发送参数', this.requestParam)
  2472. if (response.msg === 'fail') {
  2473. const tname = new RegExp("key 'tname'")
  2474. if (tname.test(response.data)) {
  2475. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2476. } else {
  2477. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2478. }
  2479. } else {
  2480. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2481. this.detail.dialogFormVisible = false
  2482. this.getList3()
  2483. this.getList2()
  2484. this.getDownList()
  2485. }
  2486. })
  2487. } else { // 现生成预混料
  2488. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2489. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2490. return false
  2491. } else if (this.detail.list2[0].tname == '') {
  2492. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2493. return false
  2494. } else if (this.detail.list2[0].ccid == '') {
  2495. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2496. return false
  2497. }
  2498. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2499. if (pattern.test(this.detail.list2[0].tname)) {
  2500. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2501. return false
  2502. }
  2503. let sumFweight = 0
  2504. for (let i = 0; i < this.detail.list.length; i++) {
  2505. sumFweight += parseFloat(this.detail.list[i].fweight)
  2506. }
  2507. sumFweight = sumFweight.toFixed(2)
  2508. console.log(sumFweight)
  2509. this.isokDisable = true
  2510. setTimeout(() => {
  2511. this.isokDisable = false
  2512. }, 1000)
  2513. if (this.detail.list2[0].tcolor == null) {
  2514. this.detail.list2[0].tcolor = '#CCCCCC'
  2515. }
  2516. this.requestParam.common = { 'returnmap': '0' }
  2517. this.requestParam.data = []
  2518. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2519. pastureid: Cookies.get('pastureid'),
  2520. tcode: this.detail.list2[0].tcode,
  2521. tname: this.detail.list2[0].tname,
  2522. tcolor: this.detail.list2[0].tcolor,
  2523. ccid: this.detail.list2[0].ccid,
  2524. ccname: this.detail.list2[0].ccname,
  2525. fttype: this.detail.list2[0].fttype,
  2526. fttypeid: this.detail.list2[0].fttypeid,
  2527. source: this.detail.list2[0].source,
  2528. remark: this.detail.list2[0].remark,
  2529. enable: this.detail.list2[0].enable
  2530. }}
  2531. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2532. this.requestParam.data[1].children = []
  2533. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2534. pastureid: '@insertSpotList.pastureid',
  2535. ftid: '@insertFT.LastInsertId',
  2536. fid: '@insertSpotList.fid',
  2537. fname: '@insertSpotList.fname',
  2538. fweight: '@insertSpotList.fweight',
  2539. islockcount: '@insertSpotList.islockcount',
  2540. sort: '@insertSpotList.sort',
  2541. feedgroup: '@insertSpotList.feedgroup',
  2542. preftid: '@insertSpotList.preftid',
  2543. autosecond: '@insertSpotList.autosecond'
  2544. }}
  2545. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2546. pastureid: '@insertSpotList.pastureid',
  2547. id: '@insertSpotList.id'
  2548. }}
  2549. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2550. this.requestParam.data[2].children = []
  2551. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2552. pastureid: Cookies.get('pastureid'),
  2553. ftid: this.table2.getdataListParm.parammaps.ftid,
  2554. fid: '@insertFT.LastInsertId',
  2555. fname: '@insertSpotList2.tname',
  2556. fweight: sumFweight,
  2557. islockcount: '0',
  2558. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2559. feedgroup: '@insertSpotList2.tname',
  2560. preftid: '@insertFT.LastInsertId',
  2561. autosecond: this.detail.list[0].autosecond
  2562. }}
  2563. ExecDataByConfig(this.requestParam).then(response => {
  2564. console.log('合成预混料保存发送参数', this.requestParam)
  2565. if (response.msg === 'fail') {
  2566. const tname = new RegExp("key 'tname'")
  2567. if (tname.test(response.data)) {
  2568. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2569. } else {
  2570. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2571. }
  2572. } else {
  2573. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2574. this.detail.dialogFormVisible = false
  2575. this.getList3()
  2576. this.getList2()
  2577. this.getDownList()
  2578. }
  2579. })
  2580. }
  2581. },
  2582. handleFormulationEvaluation(row) {
  2583. console.log(row)
  2584. // this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  2585. this.$router.push({
  2586. name: 'FormulationEvaluation',
  2587. params: {
  2588. tname: row.tname,
  2589. ftid: row.id,
  2590. pastureid: row.pastureid,
  2591. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  2592. inputDatetime: [new Date('startTime'), new Date('startTime')], // 日期后台待传
  2593. stopTime: parseTime(new Date(), '{y}-{m}-{d}')
  2594. }
  2595. })
  2596. }
  2597. }
  2598. }
  2599. </script>
  2600. <style lang="scss" scoped>
  2601. .search{margin-top:10px;}
  2602. .table{margin-top:10px;}
  2603. .table2{margin-top:10px;}
  2604. $width:350px;
  2605. $left:325px;
  2606. .selectInput{
  2607. position: relative;
  2608. display: inline-block;
  2609. .Input{width: $width;position: relative;}
  2610. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2611. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2612. .selectUl{
  2613. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2614. li{
  2615. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2616. a{float:left;width: 80px;}
  2617. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2618. }
  2619. }
  2620. }
  2621. .template{
  2622. background: #fff;
  2623. position: relative;
  2624. }
  2625. .detail{
  2626. background: #fff;
  2627. position: relative;
  2628. }
  2629. .templateDialog{
  2630. background: #fff;
  2631. position: relative;
  2632. }
  2633. .detailDialog{
  2634. background: #fff;
  2635. position: relative;
  2636. }
  2637. </style>