b592ec131d6f3a7083ba9bfc67d1e2b66589efd7.svn-base 125 KB

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